Search
 
SCRIPT & CODE EXAMPLE
 

R

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
Comment

PREVIOUS NEXT
Code Example
R :: r remove na from dataset 
R :: dplyr colnames r 
R :: how to set the first column as row names in r 
R :: how to read number of excel sheet in r 
R :: reverse row order dataframe R 
R :: how to match two time series in r 
R :: how to convert all columns of a dataframe into factors in r 
R :: merge multiple datatable in r 
R :: exponent R 
R :: list to dataframe in r 
R :: use summarize multiple columns r 
R :: r dataframe append row 
R :: remove rownumbers r 
R :: write text r 
R :: how to convert numeric to date in r 
R :: r find nas in dataframe 
R :: ggplot abline thickness 
R :: create list in r 
R :: infinite in r 
R :: select a value in a data frame R 
R :: R check object dimensions 
R :: color blind friendly palette r 
R :: r create intervals cut 
R :: add comma every 3 digits in r 
R :: timestamp conversion from excel R 
R :: r install package 
Rust :: bevy assets image as sprite 
Rust :: closure rust 
Rust :: rust String to &str 
Rust :: closure type in rust 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =