Hello,
Try the following.
x <- scan(text = "11.00 11.25 11.35 12.01 11.14 13.00 13.25 13.35 14.01
13.14 14.50 14.75 14.85 15.51 14.64 ")
hours <- floor(x)
mins <- (100*x) %% 100
as.POSIXct(paste(Sys.Date(), hours, mins), format = "%Y-%m-%d %H %M")
As you can see, there are three values of 'x' with decimal part greater
than 60, which will give mins > 60 and therefore NA date/times.
Hope this helps,
Rui Barradas
Em 31-12-2012 17:12, Christofer Bogaso escreveu:
Hello all,
Let say I have following (numeric) vector:
> x
[1] 11.00 11.25 11.35 12.01 11.14 13.00 13.25 13.35 14.01 13.14 14.50
14.75 14.85 15.51 14.64
Now, I want to create a 'Date' variable (i.e. I should be able to do
all calculations pertaining to date/time and also time-series plotting
etc.) like
2012-12-31 11:00:00 AM, 2012-12-31 11:25:00 AM, 2012-12-31 11:35:00
AM, 2012-12-31 12:01:00 PM, . . . .
Is it possible to achieve that?
Thanks and regards,
______________________________________________
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.
______________________________________________
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.