R Date origin for formatting -
i read this example using origin
set date start time. reading in csv dates number of days , read in factors.
example: $ admin_date : factor w/ 318 levels "37362","37735"
i convert date formats measure number of days , months between events. when try of different origin
such as:
df$admin_date_new <- as.numeric(df$admin_date) df$admin_date_new <- as.date(df$admin_date, origin="1900/01/01")
i following:
$ admin_date_new: date, format: "1900-08-31"
is finding correct origin
or when converting numeric
is there quick way find origin necessary? read help("as.date")
, got was:
## date given number of days since 1900-01-01 (a date in 1989) as.date(32768, origin = "1900-01-01") ## excel said use 1900-01-01 day 1 (windows default) or ## 1904-01-01 day 0 (mac default), complicated excel ## incorrectly treating 1900 leap year. ## dates (post-1901) windows excel as.date(35981, origin = "1899-12-30") # 1998-07-05 ## , mac excel as.date(34519, origin = "1904-01-01") # 1998-07-05 ## (these values come http://support.microsoft.com/kb/214330)
you don't give expected result, maybe this:
x <- factor(c("37362", "37735")) y <- as.numeric(as.character(x)) as.date(y, origin = "1900-01-01") #[1] "2002-04-18" "2003-04-26"
if don't know origin, there no way find out data.
Comments
Post a Comment