Moumita Das <das.moumita.online <at> gmail.com> writes: [snip snip snip]
> But how do i get significance of > e say:-- > recmeanC1&recmeanC2 or say recmeanC1 & i1. > I can add this in my corr function shown above but:---- > > #Finding out significance of the two items whose correlations are being > found > sig_value<-cor.test(corr_dataset) > and also return that :- > return(list(matrix=BPcor,sig=sig_value)) > > For example recmeanC1 and i1 has to be passed here..as 2 separate > dataframes,shown below if i pass the dataset for (recmeanC1 & i1 ) as as > single datframe,cor.test() function doesn't accept it.Moreover cor() > function took care of what will be crossed with what and the correlation > produced.Now do i have to manually get possible pairs of the column names of > my dataset(shown above dataset 1),and also the data and then pass to > cor.test and calculate the significance. > Isn't there any easier way to do this,with minimum number of lines of > code.Because I am dealing with huge datasets. Take a look at stats:::cor.test.default . It's pretty long and complicated but most of the complication is for dealing with different correlations (i.e., other than Pearson), and the key lines for your purposes are: r <- cor(x, y) df <- n - 2 ESTIMATE <- c(cor = r) PARAMETER <- c(df = df) STATISTIC <- c(t = sqrt(df) * r/sqrt(1 - r^2)) p <- pt(STATISTIC, df) You can incorporate this in your function. (I'm assuming you're not treating these computed values as actual probabilities of observing the data given the null hypothesis, since there is a huge multiple testing issue ...) good luck Ben Bolker ______________________________________________ R-help@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.