Skip to content

How to change variables in datasets automatically

2 messages · Liaw, Andy, Muhammad Subianto

#
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,
Andy
#
Excellent, this is exactly what I was looking for.
Many thanks and best regards,
Muhammad Subianto
On 4/29/05, Liaw, Andy <andy_liaw at merck.com> wrote: