[R] Help with POSIXct

info at mathewanalytics.com info at mathewanalytics.com
Mon Mar 21 21:31:23 CET 2011


I rarely work with dates in R, so I know very little about the
POSIXct and POSIXlt classes. I'm importing an excel file into R using
the RODBC package, and am having issues reformatting the dates.


1. The important info:
> sessionInfo()
R version 2.12.2 (2011-02-25)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                   
     
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RODBC_1.3-2

loaded via a namespace (and not attached):
[1] tools_2.12.2


2. My question:

My data looks like the following once it is imported into R.

one <- odbcConnectExcel("marketshare.xls")
dat <- sqlFetch(one, "Sheet1")
close(one)

> dat
           F1 Marvel DC
1  2010-01-01     42 34
2  2010-02-01     45 34
3  2010-03-01     47 29
4  2010-04-01     45 32
5  2010-05-01     45 35
6  2010-06-01     42 34

Variable F1, is supposed to be Jan-10, Feb-10, Mar-10, etc.
However, in the process of importing the .xls file, R is reformating
the dates. How can I retrieve the original month-year format
that I have in my excel file.


3. While the R help list discourages against asking multiple questions in 
an inquiry, it'd be really helpful if someone could point me to any good
online
resources on the POSIXct and POSIXlt classes.



More information about the R-help mailing list