[R] / Operator not meaningful for factors

John Kane jrkrideau at yahoo.ca
Tue May 4 00:50:00 CEST 2010


 I think that you are correct.  R has the annoying habit of converting character data to factors when you don't want it to while it is importing data.  This is because the in the option "stringsAsFactors" is set to TRUE for some weird historical reasons.

Try the command str(insert name of data) and see what happens.  It should show you which columns of data are being treated as factors.

You can convert the back to character or to numeric.  See the FAQ Part 7 "How do I convert factors to numeric? " or you can use the String as options command in the read.table to FALSE

Something like this should work, I think, but it's not tested
read.table("C:/rdata/trees.csv", stringsAsFactors=FALSE)





--- On Mon, 5/3/10, vincent.deluard <vincent.deluard at trimtabs.com> wrote:

> From: vincent.deluard <vincent.deluard at trimtabs.com>
> Subject: Re: [R] / Operator not meaningful for factors
> To: r-help at r-project.org
> Received: Monday, May 3, 2010, 6:22 PM
> 
> 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.
> Every time I want to compute basic operations, R returns
> "In Ops.factor: not
> meaningful for factors"
> 
> I believe it is because R does not read the data as numbers
> but I am not
> sure. Can anybody help?
> 
> Thanks! 
> -- 
> View this message in context: http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124697.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>



More information about the R-help mailing list