[R] / Operator not meaningful for factors

David Winsemius dwinsemius at comcast.net
Tue May 4 00:34:26 CEST 2010


On May 3, 2010, at 6:22 PM, vincent.deluard wrote:

>
> Hi there,
>
> This will sound very stupid because I just started using R but I see  
> you had
> similar problems.
>
> I just loaded a very large dataset (2950*6602) from csv into R. The  
> format
> is ticker=row, date=column.

Not a particularly precise description of what is in the data.


> Every time I want to compute basic operations, R returns "In  
> Ops.factor: not
> meaningful for factors"

Code .... we want to see code. All of it.
>
> I believe it is because R does not read the data as numbers

Probably true. Were they dates or numbers?

> but I am not
> sure. Can anybody help?

I generally read in my data  with read.table( ,,,,, as.is=TRUE,  
stringsAsFactors=FALSE, ....) and then convert the columns that I know  
should be numeric with as.numeric. If all of your columns should have  
been numeric, you might use the colClasses argument, perhaps along  
these lines:

rd.obj <- read.csv(file="something", colClasses= rep("numeric",  
<number-of-columns>) )

-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list