From: Adaikalavan Ramasamy <ramasamy_at_cancer.org.uk>

Date: Tue 09 Aug 2005 - 03:57:51 EST

thr <- c( 0.5, 1.0, 2.0, 3.0 )

R-help@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 Received on Tue Aug 09 04:01:27 2005

Date: Tue 09 Aug 2005 - 03:57:51 EST

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.

- Here is a reproducible example

set.seed(1) # for reproducibilityv <- 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@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
**>
*

R-help@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 Received on Tue Aug 09 04:01:27 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:39:45 EST
*