Create Data Frame of Unequal Lengths in R (Example) | Different Column Size | max, c, length & rep

Описание к видео Create Data Frame of Unequal Lengths in R (Example) | Different Column Size | max, c, length & rep

How to create a data frame with columns that have an unequal length in the R programming language. More details: https://statisticsglobe.com/create-da...
R code of this video:

x1 <- 1:8 # Create first example variable
x1 # Print first example variable

x2 <- letters[1:5] # Create second example variable
x2 # Print second example variable

max_length <- max(c(length(x1), length(x2))) # Find out maximum length
max_length # Print maximum length

data <- data.frame(col1 = c(x1, # Create data frame with unequal vectors
rep(NA, max_length - length(x1))),
col2 = c(x2,
rep(NA, max_length - length(x2))))
data # Print final data frame

Follow me on Social Media:
Facebook – Statistics Globe Page:   / statisticsglobecom  
Facebook – Group for Discussions & Questions:   / statisticsglobe  
LinkedIn – Statistics Globe Page:   / statisticsglobe  
LinkedIn – Group for Discussions & Questions:   / 12555223  
Twitter:   / joachimschork  

Music by bensound.com

Комментарии

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