I have this dataframe:

df<-structure(list(date = structure(c(1395874800, 1395874800, 1395874800,
1395874800, 1395874800), class = c("POSIXct", "POSIXt"), tzone = ""),
     hour = structure(c(-2209121804, -2209121567, -2209121005,
     -2209118616, -2209116160), class = c("POSIXct", "POSIXt"), tzone = ""),
     s.100 = c(29L, 36L, 6L, 53L, 18L)), .Names = c("date", "hour",
"s.100"), row.names = c(NA, -5L), class = "data.frame")


and I would like to sum first two columns ("date" and "hour") so that to end up 
with a new column, say "date_hour", storing both the information about the 
"date" and the "hour" in one POSIXct object;

I have been reading that POSIXct objects are a measure of seconds from a given 
origin (1st Jan 1970), so that a possible solution is to tranform the column 
"hour" into seconds and then add it to the column "date";

but, is there a staightforward solution for accomplishing this task?
I've been trying to extract from the column "hour" the digits representing 
hours, minutes and seconds and transform everything into seconds but that seem 
to me quite cumbersome approach...

and finally, one more question: is it possible to represent hundred of seconds 
as given in the column "s.100" of the given dataframe within the same new 
POSIXct object "date_hour"?


thanksfor the support

  


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to