How to split data into multiple columns in R language?
In R language, we can use the function cbind() to split data into multiple columns.
The cbind() function is used to bind objects by columns. We can pass multiple vectors, matrices, or data frames as arguments to the cbind() function, and it will bind these objects by columns.
Here is an example showing how to split the data into multiple columns.
# 创建向量
x <- c(1, 2, 3)
y <- c(4, 5, 6)
z <- c(7, 8, 9)
# 使用 cbind() 函数将向量分成多列
data <- cbind(x, y, z)
In the example above, we created three vectors x, y, and z, and then bound them by columns using the cbind() function to create a data frame called data. Each column in data corresponds to a vector.
I hope this helps you!