[R] reading Excel file

jim holtman jholtman at gmail.com
Wed Mar 26 12:06:11 CET 2008


If you want to read in the numeric values from EXCEL and the use them,
here is a function I use to go the other way -- take a POSIXct value
and convert it to what EXCEL wants.  So you can just write the inverse
of this function:

unix2EXCEL <- function (time) time/86400 + 25569


On Tue, Mar 25, 2008 at 11:41 PM, Utkarsh Singhal
<utkarshs at ambaresearch.com> wrote:
>
>
> Sorry but I was interested in reading as date format from the excel
> itself. Is there any way of doing this?
>
>
>
> Regards
>
> Utkarsh
>
>
>
>
>
>
>
> -----Original Message-----
> From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com]
> Sent: Tuesday, March 25, 2008 8:43 PM
> To: Utkarsh Singhal
> Cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] reading Excel file
>
>
>
> If d is the number of days since the Epoch then
>
>
>
> now <- Sys.Date()
>
> now - julian(now) + d
>
>
>
> will give you a "Date" class variable.  There is some info on dates in
>
> R News 4/1.
>
>
>
> On Tue, Mar 25, 2008 at 10:00 AM, Utkarsh Singhal
>
> <utkarshs at ambaresearch.com> wrote:
>
> > Hi R,
>
> >
>
> >
>
> >
>
> > I have an excel file in which the third column is "date" and others
> are
>
> > "character" and "numeric".
>
> >
>
> > Number of columns are 12
>
> >
>
> >
>
> >
>
> > 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.
>
> >
>
> >
>
> >
>
> > So I am using:                           x = read.xls("D:\\file.xls",
>
> > colClasses= c(rep("character",2),"isodate",rep("character",9)))
>
> >
>
> >
>
> >
>
> > But what can I do in case I don't know the number of columns in my
>
> > file??
>
> >
>
> >
>
> >
>
> > I mean is there any way I can specify the colClass of only third
> column
>
> > and for other columns it can take the default classes??
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > Regards
>
> >
>
> > Utkarsh
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > This e-mail may contain confidential and/or privileged
> i...{{dropped:13}}
>
> >
>
> > ______________________________________________
>
> > 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.
>
> >
>
> This e-mail may contain confidential and/or privileged i...{{dropped:13}}
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list