[R] How to change variables in datasets automatically

2005-04-29 Thread Muhammad Subianto
Dear R-helpers, Suppose I have a dataset, data(iris) a - data.frame(Sepal.Length=c(1:4), Sepal.Width=c(2:5), Petal.Length=c(3:6), Petal.Width=c(4:7), Species=rep(rosa,4)) b - iris[1:10,] newtest.iris - rbind(a,b) newtest.iris Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1

RE: [R] How to change variables in datasets automatically

2005-04-29 Thread Liaw, Andy
Try: a - data.frame(Sepal.Length=1:4, Sepal.Width=2:5, Petal.Length=3:6, Petal.Width=4:7, Species=rep(rosa,4)) b - iris[1:10,] newtest.iris - rbind(a,b) names(newtest.iris) - c(SL, SW, PL, PW, Class) newtest.iris$Class - as.numeric(newtest.iris$Class) - 1 HTH,

Re: [R] How to change variables in datasets automatically

2005-04-29 Thread Muhammad Subianto
Excellent, this is exactly what I was looking for. Many thanks and best regards, Muhammad Subianto On 4/29/05, Liaw, Andy [EMAIL PROTECTED] wrote: Try: a - data.frame(Sepal.Length=1:4, Sepal.Width=2:5, Petal.Length=3:6, Petal.Width=4:7, Species=rep(rosa,4))

Re: [R] How to change variables in datasets automatically

2005-04-29 Thread Gabor Grothendieck
On 4/29/05, Muhammad Subianto [EMAIL PROTECTED] wrote: Dear R-helpers, Suppose I have a dataset, data(iris) a - data.frame(Sepal.Length=c(1:4), Sepal.Width=c(2:5), Petal.Length=c(3:6), Petal.Width=c(4:7), Species=rep(rosa,4)) b - iris[1:10,] newtest.iris - rbind(a,b) newtest.iris