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 <jholtman@gmail.com> wrote:

> 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 convert it to character first; otherwise you
> will get the numeric value of the factor which is probably not what
> you want.
>
> On Mon, Nov 26, 2012 at 12:02 PM, Sarah Goslee <sarah.goslee@gmail.com>
> wrote:
> > 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/5963269/how-to-make-a-great-r-reproducible-example
> >
> > Sarah
> >
> > On Mon, Nov 26, 2012 at 10:59 AM, EcoFranc <robrit@gmx.de> wrote:
> >> 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
> than
> >> numeric vectors). I tried the as.numeric() command, but R says it is
> invalid
> >> to change the storage mode of a factor. Is there any way to change the
> mode
> >> of a factor into numeric.
> >>
> >> I am very grateful for help. Thank you very much, Robert.
> >>
> >>
> >
> >
> > --
> > Sarah Goslee
> > http://www.functionaldiversity.org
> >
> > ______________________________________________
> > R-help@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.
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do it.
>
> ______________________________________________
> R-help@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.
>

	[[alternative HTML version deleted]]


