Hi,
I'm pretty much an R noob and I'm missing some paradigm in R I think.
I can't figure our how to compare numerics. here's a transcript of my
tests. Any pointers?
> print(range_sd)
[1] 34.40783
> is.numeric(range_sd)
[1] TRUE
> is.numeric(foo)
[1] TRUE
> is.double(range_sd)
[1] TRUE
> is.double(foo)
[1] TRUE
>
> identical(range_sd, foo)
[1] FALSE
> identical(range_sd, 34.40783)
[1] FALSE
> identical(range_sd, 34.40783, num.eq=FALSE)
[1] FALSE
> identical(range_sd, 34.40783, num.eq=TRUE)
[1] FALSE
> library(RUnit)
Warning message:
package 'RUnit' was built under R version 2.10.1
> checkEquals(range_sd, 34.40783)
Error in checkEquals(range_sd, 34.40783) :
Mean relative difference: 5.79431e-08
> checkEquals(range_sd, foo)
Error in checkEquals(range_sd, foo) :
Mean relative difference: 5.79431e-08
> if( range_sd == 34.40783 ) { print("foo")}
> if( range_sd == "34.40783" ) { print("foo")}
> if( range_sd != "34.40783" ) { print("foo")}
[1] "foo"
> all.equal(range_sd, 34.40783)
[1] "Mean relative difference: 5.79431e-08"
______________________________________________
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.