> for(i in c(1:5))+ { + print(identical(i,1)) + } [1] FALSE [1] FALSE [1] FALSE [1] FALSE [1] FALSE Why don't I get: [1] TRUE [1] FALSE [1] FALSE [1] FALSE [1] FALSE John Welsh Associate Professor Sidney Kimmel Cancer Center 10835 Altman Row San Diego, CA 92121 (858) 450-5990 ex.282 jwelsh at skcc.org
On Fri, 12 Dec 2003, John Welsh wrote:> > > > for(i in c(1:5)) > + { > + print(identical(i,1)) > + } > > [1] FALSE > [1] FALSE > [1] FALSE > [1] FALSE > [1] FALSE > > Why don't I get: > > [1] TRUE > [1] FALSE > [1] FALSE > [1] FALSE > [1] FALSE >Because the first element of 1:5 is an integer and 1 is a real number. all.equal() will be TRUE, and == will probably be TRUE> -thomas
On Sat, 13 Dec 2003 Ted.Harding at nessie.mcc.ac.uk wrote:> On 13-Dec-03 Martin Maechler wrote: > > In general, use > > > > == for testing equality of integer numbers (of type "integer" > > or not) > > I hope this is not a suggestion to avoid usage like > > which(x == max(x)) > > when x is a vector of reals? (i.e. should be OK when you know that > the thing on one side of == should be an exact copy in its internal > representation of the thing on the other side, if equality in the > usual sense holds). > > In other words, I hope that (for instance) max(x) does not differ > internally from whichever of x[1] , ... , x[N] has the largest value ... >One reason that which.max() exists is that we cannot guarantee which(x==max(x)) to work. It is possible, though rather unlikely, for there to be no x such that x==max(x). One reason is the unpredictable use of 10-byte wide floating point registers on Intel chips. -thomas
>Hi R-MastersI found a strange error in fitdistr(): In case of VR Version 7.1-11 k21stsList<-c(0.76697,0.57642,0.75938,0.82616,0.93706,0.77377,0.58923,0.37157,0.60796,1.00070,0.97529,0.62858,0.63504,0.68697,0.61714,0.75227,1.16390,0.66702,0.83578) fitdistr(k21stsList, "normal",list(mean = 0.5, sd = 0.1)) mean sd 0.74584591 0.17908744 (0.04108548) (0.02904255) In case of VR Version 7.1-13 k21stsList<-c(0.76697,0.57642,0.75938,0.82616,0.93706,0.77377,0.58923,0.37157,0.60796,1.00070,0.97529,0.62858,0.63504,0.68697,0.61714,0.75227,1.16390,0.66702,0.83578) fitdistr(k21stsList, "normal",list(mean = 0.5, sd = 0.1)) mean sd 0.74584591 0.17908744 (0.04108548) (0.02904255) Error in fitdistr(k21stsList, "normal", list(mean = 0.5, sd = 0.1)) : supplying pars for the Normal is not supported Why this occur? []s Tura -------------- next part -------------- ---