setdiff Function in R (Example)
The following R code illustrates how to apply the setdiff() function in the R programming language.
Example Data
We create two vectors containing a different set of numeric values:
vec1 <- c(1, 2, 3, 4, 5) # Create example data vec2 <- c(1, 2, 3) |
vec1 <- c(1, 2, 3, 4, 5) # Create example data vec2 <- c(1, 2, 3)
Application of setdiff Function in R
The setdiff function can be applied as follows:
setdiff(vec1, vec2) # Apply setdiff function # 4 5 |
setdiff(vec1, vec2) # Apply setdiff function # 4 5
The values 4 and 5 do only exist in vec1, but not in vec2.
Video Examples
![YouTube](https://data-hacks.com/wp-content/plugins/borlabs-cookie/assets/images/cb-no-thumbnail.png)
By loading the video, you agree to YouTube’s privacy policy.
Learn more