[R] Selecting all values smaller than X in a dataframe

From: Christoph Scherber <Christoph.Scherber_at_agr.uni-goettingen.de>
Date: Mon, 11 Jun 2007 14:09:45 +0200


Dear R users,

I have a correlation matrix for a dataframe called "synth", for which I now want to select only those cells that have correlations larger than +/-0.6:

synth=data.frame(x=rnorm(10,1),y=rnorm(10,2),z=rnorm(10,0.5))

w=cor(synth,use="pairwise.complete.obs") w=as.data.frame(w)
w[,sapply(w,abs(w),">",0.6)]

The problem is that using sapply with ">" or "<" doesn´t seem to work.

How could I solve this problem?

Thank you very much in advance for your help!

Best wishes
Christoph

(I am using R 2.5.0 on Windows XP).

--
Christoph Scherber
DNPW, Agroecology
University of Goettingen
Waldweg 26
D-37073 Goettingen

+49-(0)551-39-8807

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 11 Jun 2007 - 12:22:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 11 Jun 2007 - 13:31:49 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.