Hi [EMAIL PROTECTED] napsal dne 28.08.2008 02:55:34:
> > 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) Read your data properly. They obviously have header so why you use header = F. rdata1<- read.table(file="data1.txt", header=T, stringsAsFactors=F) shall read it as numeric if you do not have some non numeric values somwhere. Regards Petr > >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@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. ______________________________________________ R-help@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.