For example I have a data frame like this:
df <- data.frame(x = 1:104, y = runif(104))
And I want to split it into 5 parts, and the extra 4 rows at the end of df to be in the last part of the list.
I've tried these codes but they either place those last 4 rows into the first 4 parts in z or place them into the first part of the list.
z <- split(df, rep(1:5, length.out = nrow(df), each = ceiling(nrow(df)/5)))
z <- split(df, rep(1:5, length.out = nrow(df), each = floor(nrow(df)/5)))
What I want is to split df into 5 parts, and if the row number of df isn't divisible by 5, I want to put those extra rows to be in the last part of z
Thanks and appreciating your response.