Search
 
SCRIPT & CODE EXAMPLE
 

R

r find elements in common between vectors

# Basic syntax:
intersect(vector_1, vector_2) # For two vectors
Reduce(intersect, list(vector_1, vector_2, vector_3)) # For multiple vectors

# Example usage:
vector_1 = c(1,2,3,4,5)
vector_1 = c(2,4,6,8)
intersect(vector_1, vector_2)
--> 2 4

# Note, the vectors don't have to have the same length
Comment

PREVIOUS NEXT
Code Example
R :: r how to import tsv file 
R :: list all installed packages in r 
R :: how to add random numbers randomly in a dataframe in r 
R :: remove line with na r 
R :: if not i startswith r 
R :: knnImputation in r 
R :: select all columns except one by name in r 
R :: how to transform days in years R 
R :: why is correlation na in r 
R :: r rename columns 
R :: remove all empty strings from R 
R :: comment in r 
R :: convert datetime from string r 
R :: replace na with 0 in r 
R :: how to convert negative values to positive in R 
R :: describe data in r 
R :: how to make matrix in r 
R :: read file in r EOF within quoted string 
R :: attr(* label )= chr in r 
R :: r remove regex from string 
R :: named list in r 
R :: logistic distribution CDF in r 
R :: slope by row r 
R :: how to exclude inf in r 
R :: combine scripts into a pipeline 
R :: R view storage size of variable 
Rust :: rust convertinging string to int 
Rust :: rust sort 
Rust :: length of vector rust 
Rust :: rust init vec with values 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =