"Utkarsh Singhal" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi R,

> I have an excel file in which the third column is "date" and others are
> "character" and "numeric".
>
> If I use this to read the file in R:   x = read.xls("D:\\file.xls")
>
> The problem is that my date column is read in julian dates.

RDOBC has its problems when all data in a column are not exactly the same 
data type, but can read dates:

Consider an Excel file with the following: (view with fixed-width font):

Index   Label1  Date        Number   Label2  Mixed1  Mixed2
1       A       3/1/2008     12.45   X       1       A
2       B       3/2/2008     14.76   Y       2       B
3       C       3/3/2008     10.99   Z       A       1
4       D       3/4/2008     3.14            B       2

Use this to read the excel worksheet "Sheet1":

library(RODBC)
connection <- odbcConnectExcel("C:/temp/Sample.xls")
d <- sqlFetch(connection, "Sheet1")
odbcClose(connection)

d
class(d$Date)

> d
  Index Label1       Date Number Label2 Mixed1 Mixed2
1     1      A 2008-03-01  12.45      X      1     NA
2     2      B 2008-03-02  14.76      Y      2     NA
3     3      C 2008-03-03  10.99      Z     NA      1
4     4      D 2008-03-04   3.14   <NA>     NA      2
> class(d$Date)
[1] "POSIXt"  "POSIXct"


efg
Earl F. Glynn
Bioinformatics
Stowers Institute for Medical Research

______________________________________________
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.

Reply via email to