Ryszard, I don't get your results; are you using an older version of sets?
summary(p == p) # Mode TRUE NA's #logical 26 0 q == q #[1] TRUE summary(p == gset_memberships(q)) # and this gives all TRUE values # Mode TRUE NA's #logical 26 0 sessionInfo() R version 2.11.0 alpha (2010-03-31 r51527) i386-pc-mingw32 locale: [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 [3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C [5] LC_TIME=English_Canada.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] sets_1.0-4 -Peter Ehlers On 2010-04-07 6:54, Czerminski, Ryszard wrote:
Thank you for looking into it! There is still something I do not understand (despite different numerics on different machines, etc.) On my system plain "p == p" (where p's are from runif()) gives all TRUE values, but with q (gset) which memberships values are set to p "q == q" generates FALSE Apparently memberships values are identical, tags of set members are identical (letters), but "q == q" still generates FALSE... Best regards, Ryszard p<- runif(length(letters)) q<- gset(letters, p) summary(p == p) # gives all TRUE values, but q == q # gives FALSE summary(p == gset_memberships(q)) # and this gives all TRUE valuesp<- runif(length(letters)) q<- gset(letters, p) summary(p == p) # gives all TRUE values, butMode TRUE logical 26q == q # gives FALSE[1] FALSEsummary(p == gset_memberships(q)) # and this gives all TRUE valuesMode TRUE logical 26-------------------------------------------------------------------------- Confidentiality Notice: This message is private and may contain confidential and proprietary information. If you have received this message in error, please notify us and remove it from your system and note that you must not copy, distribute or take any action in reliance on it. Any unauthorized use or disclosure of the contents of this message is not permitted and may be unlawful. -----Original Message----- From: David Meyer [mailto:david.me...@wu.ac.at] Sent: Wednesday, April 07, 2010 8:25 AM To: Czerminski, Ryszard Cc: Peter Ehlers; R-help@R-project.org; David Meyer Subject: Re: [R] library sets: A& EMPTY does not work; gset_intersection(A,EMPTY) worksThis is rather by chance due to numeric instabilities, I think:It looks like something else is going on in addition to potential problem with numerical instabilities: p<- runif(length(letters)) q<- gset(letters, p) all.equal(p,p) all.equal(q,q) q == qp<- runif(length(letters)) q<- gset(letters, p) all.equal(p,p)[1] TRUEall.equal(q,q)[1] "target and current have different memberships"q == q[1] FALSEOn my system: > p<- runif(length(letters)) > q<- gset(letters, p) > all.equal(p,p) [1] TRUE > all.equal(q,q) [1] TRUE > q == q [1] TRUE This is the same problem, since the all.equal-method for gsets does not use all.equal internally (which *is* a bug, of course!). Will be fixed ASAP ... Thanks David-------------------------------------------------------------------------- Confidentiality Notice: This message is private and may contain confidential and proprietary information. If you have received this message in error, please notify us and remove it from your system and note that you must not copy, distribute or take any action in reliance on it. Any unauthorized use or disclosure of the contents of this message is not permitted and may be unlawful. -----Original Message----- From: David Meyer [mailto:david.me...@wu.ac.at] Sent: Tuesday, April 06, 2010 6:03 PM To: Czerminski, Ryszard Cc: Peter Ehlers; R-help@R-project.org; David Meyer Subject: Re: [R] library sets: A& EMPTY does not work; gset_intersection(A,EMPTY) works This is rather by chance due to numeric instabilities, I think: > uv<- c('a', 'b', 'c'); s<- gset(uv, runif(length(uv))) > s {"a" [0.7533966], "b" [0.968067], "c" [0.2494876]} > s == s [1] TRUE > gset_is_equal(s,s) [1] TRUE But using all.equal instead of `==` for the memberships might by a good idea, I will have a look at it. Thanks David Czerminski, Ryszard wrote:Hi Peter, This looks like another one: "gset_is_equal(X,X)" and "X == X" evaluate to FALSE ?uv<- c('a', 'b', 'c'); s<- gset(uv, runif(length(uv))) s{"a" [0.0811552], "b" [0.3552998], "c" [0.996772]}gset_is_equal(s, s)[1] FALSEs == s[1] FALSEclass(s)[1] "gset" "cset" Best regards, Ryszard -------------------------------------------------------------------------- Confidentiality Notice: This message is private and may contain confidential and proprietary information. If you have received this message in error, please notify us and remove it from your system and note that you must not copy, distribute or take any action in reliance on it. Any unauthorized use or disclosure of the contents of this message is not permitted and may be unlawful. -----Original Message----- From: Peter Ehlers [mailto:ehl...@ucalgary.ca] Sent: Wednesday, March 31, 2010 2:03 PM To: Czerminski, Ryszard Cc: R-help@r-project.org; David Meyer Subject: Re: [R] library sets: A& EMPTY does not work; gset_intersection(A,EMPTY) works Ryszard, You've made me take a closer look and now I do think that you've found a bug. After a quick look at the package vignette, I see that the authors have indeed overloaded "&" and so it should work for your example. The problem seems to be the order of the class attribute which is used to call the relevant 'Ops' function: class(A) #[1] "gset" "cset" class(B) #[1] "gset" "cset" class(E<- A - A) #[1] "set" "gset" "cset" If you re-order the class vector, function Ops.gset will be called to handle A and E: class(E)<- class(E)[c(2,3,1)] A& E #{} I've cc'd David Meyer. -Peter Ehlers On 2010-03-31 10:11, Czerminski, Ryszard wrote:It seems that "A& B" works the same way as "gset_intersection(A,B)" as long as A and B are not empty... see below: fuzzy_logic("Yager", p=2) support<- universe<- c('a','b','c','d') A<- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0), universe=universe) B<- gset(support=support, memberships=c(0.211, 0.222, 0.999, 0), universe=universe) A B A& B gset_intersection(A,B) E<- A - A A& E gset_intersection(A,E)fuzzy_logic("Yager", p=2) support<- universe<- c('a','b','c','d') A<- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),universe=universe)B<- gset(support=support, memberships=c(0.211, 0.222, 0.999, 0),universe=universe)A{"a" [0.2], "b" [0.2], "c" [0.9]}B{"a" [0.211], "b" [0.222], "c" [0.999]}A& B{"c" [0.899995]}gset_intersection(A,B){"c" [0.899995]}E<- A - A A& EError in A& E : operations are possible only for numeric or logical types In addition: Warning message: Incompatible methods ("Ops.gset", "Ops.set") for "&"gset_intersection(A,E){} -------------------------------------------------------------------------- Confidentiality Notice: This message is private and may contain confidential and proprietary information. If you have received this message in error, please notify us and remove it from your system and note that you must not copy, distribute or take any action in reliance on it. Any unauthorized use or disclosure of the contents of this message is not permitted and may be unlawful. -----Original Message----- From: Peter Ehlers [mailto:ehl...@ucalgary.ca] Sent: Wednesday, March 31, 2010 11:43 AM To: Czerminski, Ryszard Cc: R-help@r-project.org Subject: Re: [R] library sets: A& EMPTY does not work; gset_intersection(A,EMPTY) works On 2010-03-31 9:30, Peter Ehlers wrote:Unless I'm missing something, I don't see any method in pkg:sets for intersection other than gset_intersection.Whoops, a bit quick on the draw. There are of course also set_intersection and cset_intersection, but not AFAICS any method for `&`. -Peter EhlersSo you're using the base R function `&` whose help page tells you that its arguments should be vectors. Yours aren't. -Peter Ehlers On 2010-03-31 8:50, Czerminski, Ryszard wrote:When using generalized sets from "sets" library A& EMPTY does not work, but gset_intersection(A,EMPTY) works: example code below Is it a bug? Best regards, Ryszard library(sets) support<- universe<- c('a','b','c','d') A<- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0), universe=universe) class(A) A E<- A - A # create empty set I<- gset_intersection(A, E) #<<< this WORKS class(I); I I<- A& E #<<< this DOES NOT WORK # ---support<- universe<- c('a','b','c','d') A<- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),universe=universe)class(A)[1] "gset" "cset"A{"a" [0.2], "b" [0.2], "c" [0.9]}E<- A - A I<- gset_intersection(A, E) #<<< this WORKS class(I); I[1] "set" "gset" "cset" {}I<- A& E #<<< this DOES NOT WORKError in A& E : operations are possible only for numeric or logical types In addition: Warning message: Incompatible methods ("Ops.gset", "Ops.set") for "&"------------------------------------------------------------------------ --Confidentiality Notice: This message is private and may...{{dropped:8}}______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
-- Peter Ehlers University of Calgary ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.