[R] Novice question about getting data into R

Silvia Lomascolo slomascolo at zoo.ufl.edu
Fri Sep 19 19:19:39 CEST 2008



> refdata =
> read.table("K:\\MerchantData\\RiskModel\\refund_distribution.csv", header
> = TRUE)
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, 
: 
  line 1 did not have 42 elements
> refdata =
> read.table("K:\\MerchantData\\RiskModel\\refund_distribution.csv")
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, 
: 
  line 2 did not have 42 elements
>
R interprets that you have 42 columns from the variable names. Do you? See
if removing spaces between column names helps (e.g., "week.1" instead of
"week 1").  Also, because yours is a csv file, fields are separated by
comas.  You can either use the "read.csv" command instead of the
"read.table" (see ?read.table for details), or add the argument sep="," to
tell R that fields are separated by comas.  You might also need to specify,
if you have empty cells, what to do with them (e.g., na.strings="")




-- 
View this message in context: http://www.nabble.com/Novice-question-about-getting-data-into-R-tp19576065p19576350.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list