Re: [R] wrong data interpretation in R

2012-11-28 Thread Greg Snow
How to change a factor to numeric is FAQ 7.10 Also look at the `colClasses` argument to read.table/read.csv for a way to specify the type of the column when you are reading it in. On Mon, Nov 26, 2012 at 8:59 AM, EcoFranc wrote: > Hi, > > maybe somebody would be kind enough to help a bloody an

Re: [R] wrong data interpretation in R

2012-11-26 Thread Richard M. Heiberger
EcoFranc, di you remember to use the argument header=TRUE ? If not, the variable name is interpreted as data and will flip you into factor rather than numeric. On Mon, Nov 26, 2012 at 12:15 PM, jim holtman wrote: > Also when reading a CSV file, if you do not want characters columns > converted

Re: [R] wrong data interpretation in R

2012-11-26 Thread jim holtman
Also when reading a CSV file, if you do not want characters columns converted to factors, use 'as.is = TRUE' as one of the parameters. If you have a column that is a factor, to convert it to numeric you have to do the following: as.numeric(as.character(factorColumn)) notice that you have to conv

Re: [R] wrong data interpretation in R

2012-11-26 Thread Don McKenzie
Robert -- it may be that some of your factor variables cannot be coerced to numeric because they have non-numeric elements. This is why we ask for a reproducible example when posting. I suspect just a few lines from the data frame would tell the story. On 26-Nov-12, at 7:59 AM, EcoFranc wrot

Re: [R] wrong data interpretation in R

2012-11-26 Thread Sarah Goslee
Most likely there's something amiss in your csv file: R won't convert numeric data to factors unless there are non-numeric characters included. First check your csv file for errors. If that doesn't solve your problem, please provide a reproducible example. http://stackoverflow.com/questions/596326

[R] wrong data interpretation in R

2012-11-26 Thread EcoFranc
Hi, maybe somebody would be kind enough to help a bloody and unprofessional beginner like me (and I hope I did not overlook the answer to my question on the website). I've imported a csv data frame into R, but I can't run a regression because R interprets 4 out of 5 variables as factors (rather th