[R] R: extracting elements in a matrix
Dimitris Rizopoulos
dimitris.rizopoulos at med.kuleuven.be
Thu Sep 22 11:42:55 CEST 2005
you could try this:
mat <- matrix(rnorm(100 * 10), 100, 10)
ind <- apply(mat, 2, function(x){
iqr <- diff(quantile(x, probs = c(0.25, 0.75)))
x[x > 2 * iqr]
})
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
----- Original Message -----
From: "Frank Schmid" <frank.schmid at vwi.unibe.ch>
To: <r-help at stat.math.ethz.ch>
Sent: Thursday, September 22, 2005 11:23 AM
Subject: [R] R: extracting elements in a matrix
> Dear R-users
>
> For a given matrix of dimension, say (n,p), I'd like to extract for
> every
> column those elements that are bigger than twice the interquartile
> range of
> the corresponding column.
>
> Can I get these elements without using a loop?
>
>
> Thank you for your help
>
>
> Frank
>
>
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
More information about the R-help
mailing list