R: deleting data in a boolean variable using a factor variable

I made the following code example to give you an idea of ​​my real data set. I have 2 data sets, a factor variable Listand a boolean variable ok.

df1 <- c("a","b","c","d","e","f","g")
df2 <- c("a","d","e")
List <- factor(as.integer(df1 %in% df2))
ok <- c(TRUE,FALSE, FALSE,FALSE,TRUE,FALSE,TRUE)

Variables Listand okhave a length of 7. I want to delete all patterns in Listwith condition TRUEc ok. For example: the first, fifth, and seventh variables must be deleted in the variable List.

Can anyone help me with this?

thank

+3
source share
2 answers

Lighter than you think.

List[!ok]
+3
source

List[!ok]? BTW, as.logical, ok logical.

0

All Articles