0

Given this df:

   A B  C
1  a 1 53
2  a 0 27
3  a 1 46
4  b 1 42
5  c 0 97
6  d 1 46
7  d 0 24

And the values defined to match for deleting are in a vector:

values_delete <- c("b", "c")

How can I delete the rows in df using a conditional with the vector? I tried:

df2 <- df[df$A != values_delete,]

But it doesn't allow it. This is the error:

longer object length is not a multiple of shorter object lengthlonger object length is not a multiple of shorter object length
1
  • 2
    df[!df$A %in% values_delete, ] ? Commented May 15, 2018 at 1:46

1 Answer 1

1

See the docs for %in%

df2 <- df[!(df$A %in% values_delete), ]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.