[R] I need to change from character to numeric?

From: kayj <kjaja27_at_yahoo.com>
Date: Wed, 27 Aug 2008 17:55:34 -0700 (PDT)

Hi,

I am reading numeric data as below but the problem is the object ndata1 and nd1 have characters instead of numeric values. I want to keep it as numeric. Why the type has changed from numeric to character and how to avoid this problem?

rdata1<- read.table(file="data1.txt", header=F,stringsAsFactors=F)
>rdata1

  V1
1 d1
2 11
3 20
4 13
rdata2
  V1
1 d2
2 1
3 7
4 5
5 6
>ndata1<-rdata1[2:nrow(rdata1),]
> ndata1

[1] "11" "20" "13"
>nd1<-cbind(ndata1,v2=0)
> nd1

     ndata1 v2

[1,] "11"   "0"
[2,] "20"   "0"
[3,] "13"   "0"

-- 
View this message in context: http://www.nabble.com/I-need-to-change-from-character-to-numeric--tp19192541p19192541.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.
Received on Thu 28 Aug 2008 - 02:32:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Aug 2008 - 10:34:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive