According to my understanding, the setdiff() function analyses two vectors and returns the elements that are present in one vector but absent in the other. Given these vectors, if that's the case, then...

item 1 - c (1,2,3)
thing2 <- c(2,3,4)\sthing3 <- c(1,2,3)\s...my here's results.

SetDifference(Thing1,Thing2) > [1] 1

SetDifference(Thing2,Thing3) > [1] 4

SetDifference(Thing1,Thing3) > Numeric (0)
Shouldn't comparing item 1 and item 2 yield the same results as comparing item 2 and item 3? How can we get a symmetric set difference result that looks like a "outer join" such that we can see all the elements that would be missing if we unioned thing1 and thing2? I would value data more than I would like to know R's functionality. tables move closer. I believe that setdiff() analyses two vectors and outputs the elements that are present in one vector but absent in the other.
Jun 22, 2022 748 views

## 1 answer to this question.

Asymmetric difference is provided by 18 setdiff. It fulfils its purpose in this instance.

Shouldn't comparing item 1 and item 2 yield the same results as comparing item 2 and item 3?

Okay, no. But the outcomes will be the same as if thing3 and thing2 were compared. Order is important. Think about your first two instances:

What does thing1 include that thing2 does not, according to the first example?

more setdiff (thing1, thing2)

[1] 1

You could try the reverse, what is in thing2 that is not in thing1?

> setdiff(thing2, thing1)

[1] 4

But it looks to me like the question you're asking is:

What elements of thing1 and thing2 are not shared?

Which is the same as:

What elements are in the union of thing1 and thing2, but

Unleash the power of data with our comprehensive Data Science Training.

• 3,040 points

## How to implement Knn-algorithm without using k-nn function in r?

I created an example that demonstrates the ...READ MORE

## Problem with sample function in R

The first time works, but after that, ...READ MORE

## To speed up the tapply function in R, or another function to convert data frame into a matrix

I must turn a sizable dataset into ...READ MORE

## In R, how to get an object's name after it is sent to a function?

I'm trying to find the opposite of ...READ MORE

## Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

## Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

The below is the code to perform ...READ MORE