【发布时间】:2013-02-19 12:57:41
【问题描述】:
如何使用 ldply()-summarise-function 中的 summary-function 来提取 p 值?
示例数据:
(预装数据框“嘌呤霉素”)
library(reshape2)
library(plyr)
Puromycin.m <- melt( Puromycin , id=c("state") )
Puro.models <- dlply( Puromycin.m , .(variable) , glm , formula = state ~ value ,
family = binomial )
我可以用提取的结果构造这个数据框:
ldply( Puro.models , summarise , "n in each model" = length(fitted.values) ,
"Coefficients" = coefficients[2] )
但我不能以同样的方式提取 p 值。我认为这会起作用,但它不起作用:
ldply( Puro.models , summarise ,
"n in each model" = length(fitted.values) ,
"Coefficients" = coefficients[2],
"P-value" = function(x) summary(x)$coef[2,4] )
如何将 p 值提取到该数据框 :) 请帮忙!
【问题讨论】:
标签: r extract plyr summary glm