how to create a table in r

To create a table in R, you can use the data.frame() function which creates a data frame object. The data.frame() function takes the data as input and returns a data frame. Here is an example of how to create a simple table with three variables:

main.r
# create some sample data
name <- c("Alice", "Bob", "Charlie")
age <- c(25, 30, 35)
gender <- c("Female", "Male", "Male")

# create a data frame
my_table <- data.frame(name, age, gender)

# view the contents of the table
my_table
230 chars
11 lines

This will output:

main.r
     name age gender
1   Alice  25 Female
2     Bob  30   Male
3 Charlie  35   Male
84 chars
5 lines

You can also add more variables to the table or modify the existing ones using various data manipulation functions in R. After creating the table, you can use various data analysis and data visualization techniques to gain insights from your data.

gistlibby LogSnag