[R] small change in output
newbie_2010
girishbogu at gmail.com
Wed Apr 28 09:27:57 CEST 2010
For every specific V1 and V4 pair (ex:A and P) calculate Linear regression of
V3(y-axis) and V2(x-axis)
and print p value along with the pair (output).
INPUT
#############
V1 V2 V3 V4
A 1 2.5 P
A 2 2.8 P
A 3 3.2 P
A 2 1.1 Q
A 3 1.7 Q
A 1 2.2 Q
B 1 2.5 P
B 2 2.9 P
B 3 3.0 P
SCRIPT
#######
data1<-read.table("INPUT", header=TRUE)
fm <- lmList(V3~V2|V1,V4 data=data1)
get.pval <- function(z) {
x <- summary(z)
pf(x$fstatistic[1L],
x$fstatistic[2L], x$fstatistic[3L], lower.tail = FALSE)
}
sapply(fm,get.pval)
OUTPUT
########
A PVALUE[LINEAR REGRESSION] P
A P........................ Q
B P........................ P
--
View this message in context: http://r.789695.n4.nabble.com/small-change-in-output-tp2068720p2068720.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list