[R] invalid factor level, NAs generated

Erik Iverson
Fri, 16 Jul 2010 19:41:20 -0000

<snip>

>
> I think I have identified the problem such that when I identify the
> structure of some of the files that I am reading in, columns are labeled as
> "Factors".  In other files, the same columns are labeled as
numeric
> values.  Is there a way to assign the data structure to these columns in
the
> dataframe as they are being read in?  Any other suggestions to why I am
> getting this error is appreciated.
>

Yes, as ?read.table describes, see the colClasses argument.

However, you should investigate why read.table wants to treat these
particular columns as factors.  If they are indeed simply consisting of
all numeric values, there shouldn't be a problem.  The fact that they
are coming out as factors raises a flag to me ...