Re: [R] reading Excel file

From: stephen sefick <ssefick_at_gmail.com>
Date: Tue, 25 Mar 2008 15:39:37 -0400

why can't you know the number of columns if it is an excel file?

On Tue, Mar 25, 2008 at 2:36 PM, Earl F. Glynn <efg_at_stowers-institute.org> wrote:
> "Utkarsh Singhal" <utkarshs@ambaresearch.com> wrote in message
> news:A36876D3F8A5734FA84A4338135E7CC3033BF22A_at_BAN-MAILSRV03.Amba.com...
>
> > 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_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.
>

-- 
Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

	-K. Mullis

______________________________________________
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.
Received on Tue 25 Mar 2008 - 20:21:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 25 Mar 2008 - 21:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive