Re: [R] reading csv-data

From: Johanna Sundvik <jsundvik_at_mail.student.oulu.fi>
Date: Mon 20 Jun 2005 - 15:30:58 EST

Thank you all for your help.

There was an easy solution to my problem:

read.csv2("example.csv", dec=".", header=TRUE) or
Mean1 <- as.numeric(as.character(Mean1))

-Johanna

Lainaus Ivar Herfindal <ivar.herfindal@bio.ntnu.no>:

>
>
> Thomas Lumley wrote:
>
> > On Fri, 17 Jun 2005, Johanna Sundvik wrote:
> >
> >>However, this "Mean1" is categorical when it should be real numbers.
> >>
> >>
> >>>Mean1
> >>
> >>[1] 4.4332 8.5113 35.1624 9.1693 2.974 65.1578 43.2241 3.1278 5.3364
> >>Levels: 2.974 3.1278 35.1624 4.4332 43.2241 5.3364 65.1578 8.5113 9.1693
> >>
> >>Why R does not understand that this should be real numbers? What am I
> doing
> >>wrong here? Thanks for your help.
> >>
> >
> >
> > Your files must have some entries that are not numbers, such as "." or
> > something. R then can't tell that the field is supposed to be numeric.
> > This may happen with missing data, in which case the na.strings= argument
> > can be used to tell R how missing data are specified.
> >
> > You can convert the data to numeric as described in FAQ 7.10
> >
> > -thomas
> >
> I think the problem can be that you use read.csv2(), which expect a
> comma (",") as decimal-indicator (as is common in Scandinavia), and a
> semi-colon (";") as separator between columns. Either you should try
> read.csv(), or you can try read.csv2("example.csv", dec=".", header=TRUE)
>
> Have a look at ?read.csv (read.csv2 is in the same help-text).
>
> Ivar
>
> ______________________________________________
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Jun 20 15:35:16 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:52 EST