[R] Obtaining correlation parameters for multiple rows

From: jpnitya <joao_at_genetics.med.harvard.edu>
Date: Thu, 24 Apr 2008 12:40:31 -0700 (PDT)


I would like to obtain correlation parameters (e.g., coefficients, p-value) for multiple samples in regard to a reference. I have my data in a table with the reference as the second row (first row are headers) and then each sample in a row. What I do so far is load up the data, get the reference sample and use "apply" and "lm" to do the regression:

x <- read.table("file.txt",header=TRUE)
x <- t(x)
ref <- x[,1]
test <- apply(x,2,function(z)lm(z~ref))

My problem is that while I can see the results in test and even obtain the F-statistic with summary for individual rows (i.e., summary(test[[1]]), I can't seem to be able to apply the summary to all rows or get only the coefficients from test so I can save them to a new file. Ideally, I would like to save a new table to a file withthe correlation coefficients and the F-statistic for each of my samples.

Any suggestions would be extremely useful.


View this message in context: http://www.nabble.com/Obtaining-correlation-parameters-for-multiple-rows-tp16851980p16851980.html
Sent from the R help mailing list archive at Nabble.com.

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 24 Apr 2008 - 20:27:46 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 Fri 25 Apr 2008 - 05:30:32 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.

list of date sections of archive