[R] [FORGED] filter correlation data
r.turner at auckland.ac.nz
Tue Jan 31 23:47:12 CET 2017
On 01/02/17 10:34, Elham - via R-help wrote:
> hello everybody,I have a very very huge table in R from calculating
> correlation,how can I filter it per spearman correlation and p-value
> before export it,I mean what is the function that I use?I want to
> select the pairs for value (r), , greater than 0.9 (directly
> correlated) and less than -0.9 (inversely corerlated), and a p-value
> < 0.001
> I should say that I transformed the big matrix in a table by
(a) In this instance it doesn't really matter, but *PLEASE* stop posting
(b) It's not at all clear what the structure of your (table? matrix?
data frame) is. Please learn to be precise and explicit, otherwise it
is difficult-to-impossible to provide useful advice. (I.e. don't expect
us to be mind-readers.)
Let us suppose (for the sake of saying *something* that might be
helpful) that your correlations and p-values are stored in a data frame
"X" as columns named "r" and "pval".
ok <- with(X, (r < -0.9 | r > 0.9) & pval < 0.001)
Y <- X[ok,]
Then export Y.
Really, if you are going to use R you should learn something about R.
P.S. Note that your p-value < 0.001 condition is redundant for any
sample size greater than or equal to 7.
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
More information about the R-help