How can you create a data frame in R language?
In R language, you can use the data.frame() function to create a data frame. Here is a simple example:
# 创建一个数据框
df <- data.frame(
ID = c(1, 2, 3, 4, 5),
Name = c("Alice", "Bob", "Charlie", "David", "Eve"),
Age = c(25, 30, 35, 40, 45)
)
# 打印数据框
print(df)
In the example above, we used the data.frame() function to create a data frame with three columns: ID, Name, and Age. We then printed out this data frame using the print() function.