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 -- "If they can get you asking the wrong questions, they don't have to worry about the answers." - Thomas Pynchon, "Gravity's Rainbow"
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 > > Andyread.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
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)