What you see is the result of 'printing' something of the class 'date'. > x <- as.date(c("1jan1960")) > x [1] 1Jan60 > str(x) Class 'date' int 0 > unclass(x) [1] 0 > getAnywhere('print.date') A single object matching print.date was found It was found in the following places registered S3 method for print from namespace survival namespace:survival with value function (x, quote, prefix, ...) { fun <- options()$print.date if (is.null(fun)) x <- date.ddmmmyy(x) else x <- get(fun)(x) if (missing(quote)) quote <- FALSE invisible(print(x, quote = quote)) } <environment: namespace:survival> > Notice that if you 'unclass' x you get the value 0 which is the number of days from 1/1/1960 of your input.
On Thu, Apr 30, 2009 at 2:16 AM, utkarshsinghal < utkarsh.sing...@global-analytics.com> wrote: > I never understood that why is the value returned by as.date function in > the library(survival) never matches with the description given in the help > file: > Following is the extract from ?as.date > > Description: > Converts any of the following character forms to a Julian date: > 8/31/56, 8-31-1956, 31 8 56, 083156, 31Aug56, or August 31 1956. > > Usage: > as.date(x, order = "mdy", ...) > > Value: > For each date, the number of days between it and January 1, 1960. > The date will be missing if the string is not interpretable. > > But here is what happens when you actually use it: > > > as.date(c("1jan1960")) > [1] 1Jan60 > > Can somebody explain this? > Also please suggest me the best function in R to convert from > as.Date("2009-08-13") to Julian and vice versa. > > Regards > Utkarsh > > ______________________________________________ > 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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]]
______________________________________________ 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.