Dimitri Shvorob wrote:
df$dt <- as.Date(df$t)
Thank you, David, but I need a *time* value. "day" was a confusing special
case; how about "min"?
Your original question was NOT clear on this point... it was not David's
fault your question was confusing, and you haven't even hinted at an
apology for leading him down the wrong path.
Nor would I call this much of an improvement in clarity... what about
"min"? You want to know the minimum? No? You want to truncate to minute?
Why then did your original "Try 2" attempt to zero out the minute
(truncate to hour)?
Perhaps the following will be enough help you figure out an answer to
whatever your question is. If it doesn't, try asking again with
consistent variable naming and sample results you want to obtain.
truncMinute <- function(dtm) {
d <- as.POSIXlt(dtm)
d$sec <- 0
as.POSIXct(d)
}
df$tt <- truncMinute(df$t)
______________________________________________
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.