One useful package is chron:
example:
library(chron)
#convert excel time to date time format
etime = 39965.0004549653
orig =chron(12/30/1899); # origin of excel time.
date.time = orig + etime;
substr(as.character(date.time), 2, 18) # as character without parentheses.
HTH,
Ken
format.
as.Date does it ALMOST but chops off the fractional seconds. POSIXct doesn't
appear to do what I need.
--
View this message in context:
http://n4.nabble.com/Excel-date-to-R-format-tp1837208p1837208.html
Sent from the R help mailing list archive at Nabble.com
I mean I want to convert them to whatever is the standard R DateTime class.
--
View this message in context:
http://n4.nabble.com/Excel-date-to-R-format-tp1837208p1837280.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r
-date-to-R-format-tp1837208p1837208.html
Sent from the R help mailing list archive at Nabble.com.
__
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
Gabor Grothendieck ggrothendieck at gmail.com writes:
See the relevant article in R News 4/1.
On Mon, Apr 12, 2010 at 10:36 AM, ManInMoon wrote:
I have a vector of double like this from Excel.
39965.0004549653
and I want to put them in R such that I can display them in any Date
Try this:
sprintf(%.3f, as.numeric(as.POSIXct(39965.004,origin=as.Date(1970-1-1
[1] 39965.004
getOption(digits.secs)
NULL
as.POSIXct(39965.004,origin=as.Date(1970-1-1))
[1] 1970-01-01 06:06:05 EST
sprintf(%.3f, as.numeric(as.POSIXct(39965.004,origin=as.Date(1970-1-1
[1] 39965.004
6 matches
Mail list logo