Dear Martin,
I'm not sure I understood you well, because you basically have the
answer already...
What about this?
A[,apply(A, 2, function(x) median(x)>0), drop=FALSE]
(drop=FALSE ensures that you keep it as column even if only one column
is selected)
HTH,
Ivan
Le 3/4/2011 11:11, Scheuringer Martin a ?crit :> Dear collegues!
>
>
> Given a matrix, I would like to remove columns, that do not fulfill a
certain condition. The condition is, that the median of the column is higher
than a certain value.
>
> I've seen the help on removing NA columns, but I cannot figure out how
to change the function part of the statement, so that the function is only TRUE
if the median of the column is higher than x;
>
> A[,apply(A, 2, function(x) all(x>=0))]
>
>
> Thank you very much,
> Regards!
>
>
>
> Martin Scheuringer
>
> ---------------------------------
> Mag. Martin Scheuringer
> Abteilung f?r Evidenzbasierte Wirtschaftliche Gesundheitsversorgung (EWG)
> Bereich Gesundheits?konomie
>
> Evidence Based Economic Health Care
> Health Economics
>
>
> Hauptverband der ?sterreichischen Sozialversicherungstr?ger
> Main Association of Austrian Social Insurance Insitututions
> Kundmanngasse 21
> 1031 Wien
> Tel.: +43-1-71132-3624
> Fax.: +43-1-71132-3786
> http://www.hauptverband.at
> P Save paper, do you really need to print this e-mail?
>
>
> [[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-help at 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.
--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. S?ugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de
**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php