[R] Getting dates in an SPSS file in right format.
Chuck Cleland
ccleland at optonline.net
Tue May 18 18:52:43 CEST 2010
On 5/18/2010 12:38 PM, Praveen Surendran wrote:
> Dear all,
>
>
>
> I am trying to read an SPSS file into a data frame in R using method
> read.spss(),
>
> sample <- read.spss(file.name,to.data.frame=TRUE)
>
>
>
> But dates in the data.frame 'sample' are coming as integers and not in the
> actual date format given in the SPSS file.
>
> Appreciate if anyone can help me to solve this problem.
Date variables in SPSS contain the number of seconds since
October 14, 1582. You might try something like this:
sample$MYDATE <- as.Date(as.POSIXct(sample$MYDATE, origin="1582-10-14",
tz="GMT"))
> Kind Regards,
>
>
>
> Praveen Surendran
>
> 2G, Complex and Adaptive Systems Laboratory (UCD CASL)
>
> School of Medicine and Medical Sciences
>
> University College Dublin
>
> Belfield, Dublin 4
>
> Ireland.
>
>
>
> Office : +353-(0)1716 5334
>
> Mobile : +353-(0)8793 13071
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
--
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list