Zoidberg_OuuuO
Zoidberg_OuuuO

Reputation: 65

splitting a dataframe into several smaller datframes with an equal number of columns

If I have a dataframe in R:

dim(df) [1] 9 705936

and I want to divide it into 28 parts by splitting it on the columns, and still have all nine rows when I am finished in each smaller dataframe. How do I do that? Because I have managed to screw this up every which way that I've tried and I'm all out of patience. It seems like this should be a one line command but I can't get it.

Upvotes: 1

Views: 206

Answers (1)

TarJae
TarJae

Reputation: 78907

Update II after testing with fake dataframe with 705936 columns (removed previous answer):

The correct answer is using split.default

split.default(df, rep(1:28, each = 25212))

Upvotes: 5

Related Questions