Re: [R] Importing an Excel spreadsheet
[EMAIL PROTECTED] 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@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@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.
Re: [R] Importing an Excel spreadsheet
I am trying to import an *.xls spreadsheet into R. I am doing this as [snip] Very steep learning curve ... so appreciate your help. By looking at http://www.R-project.org/posting-guide.html - http://cran.r-project.org/doc/manuals/R-data.pdf - Chapter 8 Reading Excel spreadsheets - you can also find my package xlsReadWrite which natively reads Excel files (Windows only). Using *.csv file is probably the more common/recommended way but be careful with 'cutted decimal places'. -- Regards, Hans-Peter [[alternative HTML version deleted]] __ 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.
Re: [R] Importing an Excel spreadsheet [SOLVED]
Hans-Peter wrote: I am trying to import an *.xls spreadsheet into R. I am doing this as [snip] Very steep learning curve ... so appreciate your help. By looking at http://www.R-project.org/posting-guide.html - http://cran.r-project.org/doc/manuals/R-data.pdf - Chapter 8 Reading Excel spreadsheets - you can also find my package xlsReadWrite which natively reads Excel files (Windows only). Using *.csv file is probably the more common/recommended way but be careful with 'cutted decimal places'. -- Regards, Hans-Peter Thanks Hans-Peter and Petr. I did use csv, but will probably, in future, use Petr's suggestion about reading from the clipboard: read.delim(clipboard) Because as it so happens, there was way too much unnecessary data in the spreadsheet. Plus I am using GNU/Linux, not Windows so some approaches won't work. I think this is now sorted. Many thanks Andy -- If they can get you asking the wrong questions, they don't have to worry about the answers. - Thomas Pynchon, Gravity's Rainbow [[alternative HTML version deleted]] __ 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.
Re: [R] Importing an Excel spreadsheet [SOLVED]
The gdata package provides a read.xls() function that will read in an Excel file that will work on any system with Perl installed. -G On Mar 21, 2008, at 6:47AM , andy wrote: Hans-Peter wrote: I am trying to import an *.xls spreadsheet into R. I am doing this as [snip] Very steep learning curve ... so appreciate your help. By looking at http://www.R-project.org/posting-guide.html - http://cran.r-project.org/doc/manuals/R-data.pdf - Chapter 8 Reading Excel spreadsheets - you can also find my package xlsReadWrite which natively reads Excel files (Windows only). Using *.csv file is probably the more common/recommended way but be careful with 'cutted decimal places'. -- Regards, Hans-Peter Thanks Hans-Peter and Petr. I did use csv, but will probably, in future, use Petr's suggestion about reading from the clipboard: read.delim(clipboard) Because as it so happens, there was way too much unnecessary data in the spreadsheet. Plus I am using GNU/Linux, not Windows so some approaches won't work. I think this is now sorted. Many thanks Andy -- If they can get you asking the wrong questions, they don't have to worry about the answers. - Thomas Pynchon, Gravity's Rainbow [[alternative HTML version deleted]] __ 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. Gregory R. Warnes, Ph.D. Associate Professor Center for Biodefence Immune Modeling and Department of Biostatistics and Computational Biology University of Rochester __ 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.
Re: [R] Importing an Excel spreadsheet
andy geek_show at dsl.pipex.com writes: I am trying to import an *.xls spreadsheet into R. I am doing this as follows: read.table(file(A5_DL.xls)) 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). Thanks Andy read.table deduces that your data set has 34 elements, not 26, according to the error message. Could there be spaces in the column names? ken __ 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.
Re: [R] Importing an Excel spreadsheet
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 -- Bryan Woods Dept. of Geology Geophysics Yale University, KGL 106D / KGL 234 210 Whitney Ave New Haven, CT 06511 203.432.5669 (office) 978.726.3462 (cell) 203.432.3134 (fax) __ 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.
Re: [R] Importing an Excel spreadsheet
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!! 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@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.