Horje
remove elements from character vector in r Code Example
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




17

Related
loop through list in r Code Example loop through list in r Code Example
r rename columns Code Example r rename columns Code Example
how to count the number of NA in r Code Example how to count the number of NA in r Code Example
r count number of na Code Example r count number of na Code Example
how to calculate variance in r Code Example how to calculate variance in r Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
14