I made a small example for my data:
mth <- c(rep(1,10))
day <- c(rep(10,5),rep(11,5))
hr <- c(3,4,5,6,7,3,4,5,6,7)
v <- c(3,4,5,4,3,3,4,5,4,3)
A <- data.frame(cbind(mth,day,hr,v))
What I need to do is to get how many value < 4 on a daily basis, I tried to use the function rle, but was not able to get what I need. The output should look like:
mth <- c(rep(1,2))
day <- c(10,11)
v <- c(2,2) #each 2 here is the sum of 1(3)+1(3) for Oct. and Nov.
A <- data.frame(cbind(mth,day,v))
Thank you for your help!
With ddply it’s easy
or you could use
summarize