Hi all, I have a data set with ~250 variables(columns). I want to calculate the correlation of one variable with the rest of the other variables and also want the p-values for each correlation. Please see the sample data and my attempt. I have got the correlation but unable to get the p-values
dat <- read.table(text="x1 x2 x3 x4 1.68 -0.96 -1.25 0.61 -0.06 0.41 0.06 -0.96 . 0.08 1.14 1.42 0.80 -0.67 0.53 -0.68 0.23 -0.97 -1.18 -0.78 -1.03 1.11 -0.61 . 2.15 . 0.02 0.66 0.35 -0.37 -0.26 0.39 -0.66 0.89 . -1.49 0.11 1.52 0.73 -1.03",header=TRUE) #change all to numeric dat[] <- lapply(dat, function(x) as.numeric(as.character(x))) data_cor <- cor(dat[ , colnames(dat) != "x1"], dat$x1, method = "pearson", use = "complete.obs") Result [,1] x2 -0.5845835 x3 -0.4664220 x4 0.7202837 How do I get the p-values ? Thank you, ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.