[R] Eliminate Factors from Data Frame

David Winsemius dwinsemius at comcast.net
Wed Mar 4 21:53:46 CET 2009


It's in the R-FAQ. I can't remember it's 7.20 or 7.35 but it's in that  
general area.

-- 
David Winsemius


On Mar 4, 2009, at 3:38 PM, Bob Roberts wrote:

> Hi,
>   I formed a 49 by 3 data frame by reading in a text file using  
> read.table(), and combining it with a matrix that I made by using  
> unlist() on a list of character strings. I would like to do some  
> simple arithmetic operations on the elements in the data frame  
> columns (e.g. column 3/column2) but the values in the data frame are  
> stored as factors and using stringsAsFactors=FALSE did not work. I  
> get this error when doing arithmetic operations:
> In Ops.factor(dataframe$col3, dataframe$col2) : / not meaningful for  
> factors
> Is there a way to store these values not as factors or convert them  
> to numeric values? Or a way to do operations on factors in data  
> frames? I know R has I() but that didn't help in this case. Thanks  
> so much.
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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