Combine Two Vectors into Data Frame or Matrix in R (2 Examples) | data.frame & cbind Functions

preview_player
Показать описание
R code of this video:

vec1 <- 1:10 # Create first vector
vec1 # Print first vector

vec2 <- letters[1:10] # Create second vector
vec2 # Print second vector

my_data # Print data frame

my_matrix <- cbind(vec1, vec2) # Apply cbind function
my_matrix # Print matrix

Follow me on Social Media:
Рекомендации по теме
Комментарии
Автор

Thank you so very much, Herr Professor. The clarity and concision is of your videos is so very apropos to the subject about which you teach.

shurjendu
Автор

I am guessing r bind would be a way to combine two vectors that are the flipped 90 degrees

vanhoot
Автор

Another excellent video, thank you Joachim. I see in your Environment pane that my_matrix is described as chr [1:10, 1:2]. I followed exactly what you did and I also get a two-column matrix but in my Environment pane it describes my_matrix as chr [1:20]. Is this something that has changed with an update to R or am I missing something?

michaelhudson
visit shbcf.ru