split & unsplit Functions in R (2 Examples) | Divide & Reassemble Data | Vector Object into Chunks

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

vec <- 1:10 # Create example vector
vec # Print example vector

groups <- c(rep("A", 3), # Create grouping vector
rep("B", 5),
rep("C", 2))
groups # Print grouping vector

my_split <- split(vec, groups) # Apply split function
my_split # Print output

my_unsplit <- unsplit(my_split, groups) # Apply unsplit function
my_unsplit # Print output

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

Interesting video. I have heard of unlist and also nest and unnest (tidyverse I believe). How are those related to these split/unsplit functions? Thanks!

haraldurkarlsson
visit shbcf.ru