[R] sample (randomly select) from successive days
Dagmar Cimiotti
d@gm@r@cimiotti @ending from ftz-we@t@uni-kiel@de
Fri Dec 7 09:36:48 CET 2018
Dear all,
I have data from a time span like this:
myframe <- data.frame (Timestamp=c("24.09.2012 09:00:00", "24.09.2012 10:00:00","25.09.2012 09:00:00",
"25.09.2012 09:00:00","24.09.2012 09:00:00", "24.09.2012 10:00:00"),
Event=c(50,60,30,40,42,54) )
myframe
I want to create a new dataframe which includes in this example the data from two successive days (in my real data I have a big time span and want data from 25 consecutive days). I understand that I can do a simple sample like this
mysample <- myframe[sample(1:nrow(myframe), 4,replace=FALSE),]
mysample
But I need the data from consecutive days in my random sample. Can anyone help me with this?
Many thanks in advance,
Dagmar
More information about the R-help
mailing list