[R] Simple numeric

Gabor Grothendieck ggrothendieck at myway.com
Mon Mar 15 20:37:09 CET 2004



Regarding the flame, your might be interested in the following:

   read.table(myfile, as.is=T)

which will interpret character columns as character rather
than factor and still reads in the numeric columns as numbers.
You can also specify specific columns such as as.is=3:4 if you
want columns 3 and 4 to be character but other character columns
to be factors.

---
Date:   Mon, 15 Mar 2004 11:04:08 -0500 (EST) 
From:   Tom Blackwell <tblackw at umich.edu>
To:   Janet Gannon <jangann at mote.org> 
Cc:   <r-help at stat.math.ethz.ch> 
Subject:   Re: [R] Simple numeric "as.is" question 

 
Janet -

Try x2 <- as.numeric(as.character(x))
hist(x2)

I'm not a Windows user, so I can't test this before sending.
It might solve the problem, might not.

(Flame !! : This is just ONE MORE example of the difficulties
caused by the default behavior of read.table() to make things
into factors. I sincerely wish the default were to preserve
character data as character.)

- tom blackwell - u michigan medical school - ann arbor -

On Mon, 15 Mar 2004, Janet Gannon wrote:

> I am reading a list of numbers from my clipboard, and have been
> successful, except I can't make a histogram as R doesn't recognize my
> variable as numeric. I know I need to use "as.is", but the specifics
> escape me.
>
> I have used x<-read.table("clipboard", header=F) to import from a txt
> file. How do make this numeric? Thanks, J.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list