Per Månsson
Per Månsson

Reputation: 721

How do I exclude multiple elements in a vector by position?

I want to pick elements from a vector and exclude 3 values by what position they got.

I know about the x[-n] function to exclude a single value but I don´t know how to exclude more than one.

Upvotes: 2

Views: 5560

Answers (1)

Sven Hohenstein
Sven Hohenstein

Reputation: 81693

You could use the c function to combine the values into a vector:

a <- 1:10
a[-c(1,2,3)]
[1]  4  5  6  7  8  9 10

Upvotes: 10

Related Questions