[R] Set Difference Problem
Neha Aggarwal
aggarwalneha2000 at gmail.com
Sun Mar 18 10:34:31 CET 2018
Hello All,
I am facing a problem and am unable to find much help online as sets
package in R is relatively new.
My problem is as follows:
Set R is made of 2 sets x and y
x<-{"P1", "P2", "P3", "P4"}
y<-{}
R<-set(x,y)
#R={{}, {"P1", "P2", "P3", "P4"}}
i need to use R in a recursive loop where i need to take set difference of
R and it 's elements.
Example:
for (r in R){
print(r)
R<-set_symdiff(r,R)
print(R)
}
the program is unable to recognise the null set in the set R. I tried
various funtions and methods:
> R-r
#Output : {{}, {"P1", "P2", "P3", "P4"}}
> set_symdiff(r,R)
Output: {{}, {"P1", "P2", "P3", "P4"}}
> set_symdiff(R,r)
Output: {{}, {"P1", "P2", "P3", "P4"}}
i also tried with set_complement() .But they do not subtract the null set
from the bigger set. It seems they dont recognise it.
What can I try, any pointers/ packages will be great help.
Please help
.
Thanks,
Neha
[[alternative HTML version deleted]]
More information about the R-help
mailing list