Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

R Programming: Find elements come only once that are common to both given data frames

R Programming: Data frame Exercise-21 with Solution

Write a R program to find elements come only once that are common to both given data frames.

Sample Solution:

R Programming Code:

a = c("a", "b", "c", "d", "e")
b = c("d", "e", "f", "g")
print("Original Dataframes")
print(a)
print(b)
print("Find elements come only once that are common to both given dataframes:")
result = union(a, b)
print(result)

Sample Output:

[1] "Original Dataframes"
[1] "a" "b" "c" "d" "e"
[1] "d" "e" "f" "g"
[1] "Find elements come only once that are common to both given dataframes:"
[1] "a" "b" "c" "d" "e" "f" "g"

R Programming Code Editor:



Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a R program to find elements which are present in two given data frames.
Next: Write a R program to save the information of a data frame in a file and display the information of the file.

Test your Programming skills with w3resource's quiz.

What is the difficulty level of this exercise?