cbind Function in R (3 Examples) | How to Column Bind Data Frame, Vector & Multiple Columns

Описание к видео cbind Function in R (3 Examples) | How to Column Bind Data Frame, Vector & Multiple Columns

How to merge data objects by columns with the cbind command in the R programming language. Mode details: https://statisticsglobe.com/cbind-r-c...
R code:


##### Example 1
data_1 <- data.frame(x1 = c(7, 3, 2, 9, 0), # Column 1 of data frame
x2 = c(4, 4, 1, 1, 8), # Column 2 of data frame
x3 = c(5, 3, 9, 2, 4)) # Column 3 of data frame

y1 <- c(9, 8, 7, 6, 5) # Create vector

data_new1 <- cbind(data_1, y1) # cbind vector to data frame

##### Example 2
data_2 <- data.frame(z1 = c(1, 5, 9, 4, 0), # Column 1 of data frame 2
z2 = c(0, 9, 8, 1, 6)) # Column 2 of data frame 2

data_new2 <- cbind(data_1, data_2) # cbind two data frames in R

##### Example 3
data_new3 <- cbind(data_1, y1, data_2) # cbind two data frames and vector

Комментарии

Информация по комментариям в разработке