comparing two numerical varialbes in R -


i have run r function stl() function , use generated residuals grubbs test. code following:

stl.res = stl(dataset, s.windows='periodic') residuals = as.numeric(strl.res$time.series[, "remainder"]) grubbs.result = grubbs.test(residuals)  strsplit(grubbs.result$alternative," ")[[1]][3] ## [1] "38.4000349179783"  outlier = as.numeric(strsplit(grubbs.result$alternative," ")[[1]][3]) outlier ## [1] 38.40003492  which(residuals == outlier) ## integer(0) 

my question why return value of which() 0. residuals[1920] = 38.4000349179783. call of which() should return value of 1921, not 0. guess problem precision. have tried many ways, not managed solve it.

any appreciated.

if it's precision issue (which r faq 7.31), there various ways around it.

# approximation of test x <- c(1, 2, 38.4000349179783, 4, 5) y <- 38.40003492  > x == y [1] false false false false false # doesn't return   # 1 basic approach  > which(abs(x - y) < .00001) [1] 3 

you rig using all.equal(), checking difference less pre-selected limit easiest.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -