[R] sum per day

Tagmarie Ramgad82 at gmx.net
Tue Nov 27 10:13:15 CET 2012


Hello, 

I have a data frame somewhat like this one: 

myframe <- data.frame (Timestamp=c("24.09.2012 09:00", "24.09.2012 10:00",
"24.09.2012 11:00", 
                                   "25.09.2012 09:00", "25.09.2012 10:00",
"25.09.2012 11:00"), Hunger=c(1,1,1,2,2,1) )                                  
myframestime <- as.POSIXct (strptime(as.character(myframe$Timestamp),
"%d.%m.%Y %H:%M"), tz="GMT")
myframe2 <- cbind (myframe,myframestime)
myframe2$Timestamp <- NULL  
myframe2

Now I want to get the sum of "Hunger" for each day. In the end I want
something which looks like the following dataframe: 

myoutcome <- data.frame(Timestamp=c("24.09.2012", "25.09.2012"),
sumHunger=c(3, 5))

Does anyone know how to do that?
That would be very helpful and to all people who are willing to help me:
Thank you in advance! 

Best regards, 
Tagmarie 



--
View this message in context: http://r.789695.n4.nabble.com/sum-per-day-tp4650937.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list