Answers for "remove rows from matrix matching any element in character vector r"

R
5

remove elements from character vector in r

x<-c(2, 4, 6, 9, 10) # the list
y<-c(4, 9, 10) # values to be removed

idx = which(x %in% y) # Positions of the values of y in x
x = x[-idx] # Remove those values using their position and "-" operator


x = x[ - which(x %in% y)] # In short
x = x[! x %in% y] # You can also try
Posted by: Guest on February-05-2021
0

delete rows from string vector r according to regex

df[ grep("REVERSE", df$Name, invert = TRUE) , ]
Posted by: Guest on May-24-2020

Code answers related to "remove rows from matrix matching any element in character vector r"

Browse Popular Code Answers by Language