[R] Numeric data not numeric in .csv file

David Winsemius dwinsemius at comcast.net
Wed May 2 16:09:00 CEST 2012


On May 1, 2012, at 8:47 PM, Eve Proper wrote:

> I am a raw novice to R, playing around with a mini .csv dataset  
> created in
> Excel. I can read it in and the data looks OK in Excel and upon  
> initial
> inspection in R:
>
> hikes <- read.csv("/Users/eproper/Desktop/hikes.csv", header=TRUE)
> print(hikes)
>
> does exactly what it is supposed to do.
>
> Two of the variables are genuine strings, but the others ought to be
> numeric, and R will calculate their min, max etc. However, is.numeric
> returns FALSE for all of them;

How did you do this? What code did you use? It should have been:

lapply(hikes, is.numeric)

> storage.mode returns "language."

Well, that suggests that you were trying to use unquoted variable  
names without the data objects name. Did you use attach() on the basis  
of some misguided instructions?


> as.numeric
> returns "Error: 'pairlist' object cannot be coerced to type  
> 'double'." In
> what I suspect is a related problem, any command that calls for a  
> variable
> name requires an initial ~ to work. That is, instead of plot(miles)  
> I have
> to use plot(~miles).

As I said, you are not correctly referencing column names within data  
objects.

>
> No doubt there is some very elementary mistake I am making, but I  
> can't
> figure it out. Any help would be appreciated.
>
> <http://theturducken.blogspot.com/>
>
> 	[[alternative HTML version deleted]]

And you should read the Posting Guide and correct your posting format.

>
> ______________________________________________
> 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list