[R] vector of factors to POSIXlt

Siddique, Amer Amer.Siddique at ssa.gov
Fri Feb 6 21:10:46 CET 2004


hello,
I have a vector of factors
> str(rcptdt)
 Factor w/ 51 levels "1/10/03","1/13/03",..:
> length(rcptdt)
[1] 87

which i want to convert to class POSIXlt to extract the day, so:
a1<-format(rcptdt,"%m/%d/%y")
> length(a1)
[1] 87

and:
a2<-strptime(a1, "%m/%d/%y")
str(a2)
`POSIXlt', format: chr [1:87] "2002-04-18" "2002-07-19" "2002-08-02"
"2002-08-14" ...
> a2[1]-a2[2]
Time difference of -92 days

but the length differs 
> length(a2)
[1] 9

and i cant update rcptdt...

> version
         _              
platform i386-pc-mingw32
arch     i386           
os       mingw32        
system   i386, mingw32  
status                  
major    1              
minor    8.1            
year     2003           
month    11             
day      21             
language R 

thanks,

amer
research analyst
disability det. bureau
madtown-wi-usa




More information about the R-help mailing list