Re: [R] Importing an Excel spreadsheet

From: Petr PIKAL <petr.pikal_at_precheza.cz>
Date: Fri, 21 Mar 2008 08:28:10 +0100

r-help-bounces_at_r-project.org napsal dne 20.03.2008 23:44:05:

> Bryan K Woods wrote:
> > If you open the spreadsheet in Excel you can then do "Save as..." and
> > select type CSV (comma-delimited text). Once you have the data in CSV
> > format, you can use the R function read.csv to import the data.
> >
> > Cheers,
> > Bryan
> >
> > andy wrote:
> >> Hello
> >>
> >> I am trying to import an *.xls spreadsheet into R. I am doing this as

> >> follows:
> >>
> >> > read.table(file("A5_DL.xls"))
> >>
> >> But obtain the error:
> >>
> >> Error in type.convert(data[[i]], as.is = as.is[i], dec = dec,
> >> na.strings = character(0)) :
> >> invalid multibyte string at '?????'
> >>
> >> So I copied it all over to a text document and tried to import that,
> >> thus:
> >> > read.table("A5.txt")
> >>
> >> The error I got then was:
> >>
> >> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
> >> na.strings, :
> >> line 26 did not have 34 elements
> >>
> >> Having gone over the line in question, it all seems to be the same as

> >> any other row. I really don't want to have to manually re-enter the
> >> data (some 98 rows x 26 columns).
> >>
> >> Can someone advise me on what I am overlooking here please.
> >>
> >> Thanks
> >>
> >> Andy
> >>
> >>
> >
> That did it - thanks!!

Or you can in Excel select the part in question, press Ctrl-C and in R write

mydata <- read.delim("clipboard")

Regards

Petr

>
> Very steep learning curve ... so appreciate your help.
>
> Cheers
>
> Andy
>
> --
>
> "If they can get you asking the wrong questions, they don't have to
worry
> about the answers." - Thomas Pynchon, "Gravity's Rainbow"
>
> ______________________________________________
> 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.



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 Fri 21 Mar 2008 - 07:32:41 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 Fri 21 Mar 2008 - 08:30:23 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