[R] Error in make.names when trying to read.table in if statement

Cynthia Sadler cynthia.sadler at unboundid.com
Mon Sep 21 18:19:40 CEST 2009


Hi,

I'm trying to read data from a collection of CSV files for processing  
and graphing. All of my files begin with "modrate" and end with  
".csv". I think I have the regex working but I am stumped at trying to  
get read.table to work within an if statement.

This works:

 > filepattern="modrate*"
 > files <- list.files(pattern=filepattern)
 > data <- read.table(files[1], header=TRUE, sep=",")

But I cannot get this to work:

 > for (i in seq(along=files)) {
+ data <- read.table(files[i], header=TRUE, sep=",")
+ }
Error in make.names(col.names, unique = TRUE) :
   invalid multibyte string at '<ff><d8><ff><e0>'

I'm sure I'm making a newbie mistake here. I'm using R version 2.9.2  
(2009-08-24) on Mac OS X, and didn't find anything about this in the  
help archives (though, as I'm new to this, I may not have searched in  
the best way). Any advice? Thanks.

Kind regards,
Cynthia


More information about the R-help mailing list