Skip to content
Prev 312619 / 398506 Next

How to re-combine values based on an index?

On 02-12-2012, at 06:06, Brian Feeny wrote:

            
Change you example to make it actually do something

data(iris)
index_setosa <- which(iris$Species == "setosa")
iris_setosa <-iris[index_setosa,]
head(iris_setosa)

# iris_others <- data.frame()
# iris_others[-index_setosa,] <- iris[-index_setosa,]
iris_others <- iris[-index_setosa,]
head(iris_others)
tail(iris_others)

The head() and tail() calls are for checking.
Combine the two like this

z <- rbind(iris_setosa,iris_others)
head(z)
tail(z)

Berend