[R] sample (randomly select) from successive days

2018-12-07 Thread Dagmar Cimiotti
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

Re: [R] sample (randomly select) from successive days

2018-12-07 Thread Dagmar Cimiotti
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 wrote: Dear all, I have data from a time span like this: myframe <- data.frame (Timestamp=c("24.09.201

[R] sample (randomly select) to get a number of successive days

2018-12-07 Thread Dagmar Cimiotti
$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 > wrote: >> Dear all, >> >

Re: [R] sample (randomly select) to get a number of successive days

2018-12-09 Thread Dagmar Cimiotti
? Regards, Marc Schwartz > On Dec 7, 2018, at 7:18 PM, Dagmar > Cimiotti wrote: > > Hi Jim and everyone else, > > Mhm, no this is not what I am looking for. I think in your way I would > randomly sample two values of day 1 and of day 2. But I want the > opposite: I w

Re: [R] sample (randomly select) to get a number of successive days

2018-12-10 Thread Dagmar Cimiotti
] "2012-10-14" "2012-10-15" "2012-10-16" "2012-10-17" "2012-10-18" Now, use the result of the above to subset your data frame. See ?subset and ?"%in%": myframe.rand <- subset(myframe, day %in% seq(start, length.out = 25, by = &quo

[R] rbind - names in dataframe. Beginner Question

2015-10-28 Thread Dagmar Cimiotti
Hello, It must be very easy. I have data like this: myframe <- data.frame (ID=c("Ernie", "Ernie", "Ernie", "Bert", "Bert","Bert", "Duck"), Hunger=c(1,1,1,2,2,1,3) ) myframe bighunger <- subset (myframe, myframe$Hunger>=2 &myframe$Hunger <3 ) bighunger verybighunger <- subset(myframe,myframe$Hun