[R] Obtaining correlation parameters for multiple rows

jpnitya joao at genetics.med.harvard.edu
Thu Apr 24 21:40:31 CEST 2008


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.

More information about the R-help mailing list