Back to Browse

intersect Function in R (2 Examples) | Intersection of Vectors & Data Frames | Base R, dplyr Package

1.1K views
Oct 28, 2022
5:48

How to return the intersection of two data objects using an intersect() function in the R programming language. More details: https://statisticsglobe.com/intersect-function-r R code of this video: x1 <- letters[1:5] # Create first vector object x1 # Print first vector object x2 <- letters[3:6] # Create second vector object x2 # Print second vector object x1_x2_inter <- base::intersect(x1, x2) # Apply intersect function to vectors x1_x2_inter # Print intersection of vectors data1 <- data.frame(col1 = 1:5, # Create first data frame col2 = letters[1:5]) data2 <- data.frame(col1 = 3:6, # Create second data frame col2 = letters[3:6]) install.packages("dplyr") # Install & load dplyr library("dplyr") data_1_2_inter <- dplyr::intersect(data1, data2) # Apply intersect function to data frames Follow me on Social Media: Facebook – Statistics Globe Page: https://www.facebook.com/statisticsglobecom/ Facebook – R Programming Group for Discussions & Questions: https://www.facebook.com/groups/statisticsglobe Facebook – Python Programming Group for Discussions & Questions: https://www.facebook.com/groups/statisticsglobepython LinkedIn – Statistics Globe Page: https://www.linkedin.com/company/statisticsglobe/ LinkedIn – R Programming Group for Discussions & Questions: https://www.linkedin.com/groups/12555223/ LinkedIn – Python Programming Group for Discussions & Questions: https://www.linkedin.com/groups/12673534/ Twitter: https://twitter.com/JoachimSchork Music by bensound.com

Download

0 formats

No download links available.

intersect Function in R (2 Examples) | Intersection of Vectors & Data Frames | Base R, dplyr Package | NatokHD