> I had been thinking of: > > x <- c(1, (2^(0.5))^2 , 3, 5, (2^(0.5))^2 , 3, 1) > > y <- 2 > > x[-which(zapsmall(x-y) == 0)] > [1] 1 3 5 3 1
Using which() to convert logicals into integer subscripts is almost always unnecessary and often wrong. In this case it fails when no x is close to y, because integer(0) is the same thing as -integer(0): > x[-which(zapsmall(x-10) == 0)] numeric(0) The whichless version, using logical subscripts, works (in this case we want all of x): > x[zapsmall(x-10)!=0] [1] 1 2 3 5 2 3 1 When using logicals as subscripts, read the "[" as "such that". Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com ______________________________________________ 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.