General Notes :
a) Please try to give a simple example
b) Please avoid the rightwards assignment (i.e. "->"). Eventhough
it is
perfectly legal to use it, it is confusing especially when you are
posting to a mailing list.
1) Here is a reproducible example
set.seed(1) # for reproducibility
v <- abs( rnorm(1000) )
thr <- c( 0.5, 1.0, 2.0, 3.0 )
2) If you simply want to count the number of points above a threshold
sapply( thr, function(x) sum(v > x) )
[1] 620 326 60 3
3) Or you can cut the data by threshold limits (be careful at the edges
if you have discrete data) followed by breaks
table( cut( v, breaks=c( -Inf, thr, Inf ) ) ) )
(-Inf,0.5] (0.5,1] (1,2] (2,3] (3,Inf]
380 294 266 57 3
4) If you want to turn the problem on its head and ask for which
threshold point would you get 99%, 99.9% and 99.99% of the data below
it, you can use use quantiles
quantile( v, c(0.99, 0.999, 0.9999) )
99% 99.9% 99.99%
2.529139 3.056497 3.734899
Regards, Adai
On Mon, 2005-08-08 at 08:34 -0700, alessandro carletti
wrote:> Hi!
> OK, I'm trying to select some "useful outliers" from
> my dataset: I defined 11 "treshold" values (1 for each
> level of a variable (sampling site) as follows:
>
>
> tresholds<-function(x)
> {
> tapply(x,mm$NAME,FUN=mean ,simplify = T, na.rm=T)->med
>
>
> tapply(x,mm$NAME,FUN=sd ,simplify = T,
> na.rm=T)->standev
>
> standev+med
>
> }
> tresholds(mm$chl)
>
>
> Now I'd like to select those values from vector mm$chl
> that are higher than each "treshold value", but how
> can I compare a vector with 1885 elements with the one
> with 11?
> Sorry for this (probably) stupid question...
> and thanks in advance.
> Alessandro
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>