[R] How to split a dataframe into smaller constituent dataframes
edd at debian.org
Mon May 19 00:27:41 CEST 2003
On Sun, May 18, 2003 at 10:11:11PM +0000, Neil Osborne wrote:
> I have read a large dataset into a dataframe using RODBC, the rows of data
> in the dataframe are (integer) timestamped and I would like to divide the
> original dataframe into n smaller dataframes where dataframe 1 contains all
> rows that had timestamps falling in the period 0-x1 minutes, dataframe 2
> contains all rows that had timestamps falling between x1+1 and x2, etc..
> Does anyone know how to do this?
I would convert all your dates to DateTimeClass (i.e. POSIXct or POSIXlt),
e.g. using strptime, and then loop over them doing your subsetting at each
grid step you specify. R really has excellent facilities to compute on, or
compare, dates up to Unix timestamp precision.
Alternatively, if the data lives in a DBMS you could simply tailor your
queries to the desired grid sizes and retrieve individual chunks and store
Don't drink and derive. Alcohol and analysis don't mix.
More information about the R-help