I am doing an experiment which produces automatically logged data. The software produces a timestamp that is of the format 41149.014850. I would like to convert this decimal timestamp to 28.08.2012 00:21:23. How can I do this in R most elegantly?
I tried using the function strsplit and also the function as.Date with a specified origin, and also the times function. But to no avail. I have problems in splitting the timestamp into two numbers that I can access with the functions as.Date and times.
Here is some demo code:
myDatetime <- c(41149.004641, # 28.08.2012 00:06:41
41149.009745, # 28.08.2012 00:14:02
41149.014850, # 28.08.2012 00:21:23
41149.019954) # 28.08.2012 00:28:44
## not working out for me
Dat.char <- as.character(myDatetime)
date.split <- strsplit(Dat.char, split = "\\.")
## how to proceed from here, if it is a good way at all
You dates are in an Excel-like date format (days after January 1, 1900), so you need to convert them to an R date format. Then you can convert it to a datetime format (
POSIXct).