I have a dataframe that contains 240,000 obs. of 7 variables. In the dataframe there are 100 groups of 2400 records each, by Symbol
. Example:
I want to split this dataframe in new dataframe that contains every first observation and each 240 observation.
The new dataframe will be 1000 obs of 7 variables:
I tried df[seq(1, nrow(df), 240), ]
but the new dataframe has each 240 observation and not distinguished by group (Symbol
). I mean, I want a new dataframe that contains the rows 240, 480, 720, 960, and so on, for each symbol. In the original data frame every symbol has 2400 obs thus the new dataframe will have 10 obs by group.