Re: [R] how to convert character variables into numeric variables directly

2010-03-08 Thread Xumin Zeng
Thanks, it works! Xumin milton ruser 03/08/2010 01:02 PM To Xumin Zeng cc r-help Subject Re: [R] how to convert character variables into numeric variables directly Try: as.numeric(as.character( typec)) milton On Mon, Mar 8, 2010 at 12:55 PM, Xumin Zeng wrote: Here is the example

Re: [R] how to convert character variables into numeric variables directly

2010-03-08 Thread milton ruser
Try: as.numeric(as.character( typec)) milton On Mon, Mar 8, 2010 at 12:55 PM, Xumin Zeng wrote: > Here is the example. > > > age=18:29 > > height=c(76.1,77,78.1,78.2,78.8,79.7,79.9,81.1,81.2,81.8,82.8,83.5) > > type=c("A", "B", "C", "D","A", "B", "C", "D","A", "B", "C", "D") > > typec=c("0","4",

[R] how to convert character variables into numeric variables directly

2010-03-08 Thread Xumin Zeng
Here is the example. > age=18:29 > height=c(76.1,77,78.1,78.2,78.8,79.7,79.9,81.1,81.2,81.8,82.8,83.5) > type=c("A", "B", "C", "D","A", "B", "C", "D","A", "B", "C", "D") > typec=c("0","4","2","9","0","7","2","3","0","1","2","3") > typen=c(0,1,2,3,0,1,2,3,0,1,2,3) > data1=data.frame(age=age,height=