Skip to content
Prev 377656 / 398502 Next

sample (randomly select) from successive days

Hi Dagmar,
This will probably involve creating a variable to differentiate the
two days in each data.frame:

myframe$day<-as.Date(as.character(myframe$Timestamp),"%d.%m.%Y %H:%M:%S")
days<-unique(myframe$day)

Then just sample the two subsets and concatenate them:

myframe[c(sample(which(myframe$day==days[1]),2),
 sample(which(myframe$day==days[2]),2)),]

Jim


On Fri, Dec 7, 2018 at 8:08 PM Dagmar Cimiotti
<dagmar.cimiotti at ftz-west.uni-kiel.de> wrote: