[R] Getting a table of coefficients from R

danibelle at talk21.com danibelle at talk21.com
Thu Oct 18 17:06:12 CEST 2012


Hi, 

I'm trying to obtain a table of coefficients and confidence intervals from a logistic regression analysis in R. My code is as follows:

# read in csv file

datafile<-read.csv("file.csv", row.names=1)
# read in the variable list
varlist<-names(datafile)[66:180]
models<-lapply(varlist, function(x) {glm(substitute(outcome ~ i, list(i=as.name(x))), data=datafile, family = "binomial")})

# apply summary to each model stored in the list, models

lapply(models, summary)

tableofOddsRatios<-exp(cbind(OR = coef(models), confint(models)))
write.table(table, "tableofOddsRatios_outcome.txt", sep="\t", row.names=T, col.names=T, quote=F)

When I try to run this, I get the following error message:
> tableofOddsRatios<-exp(cbind(OR = coef(models), confint(models)))
Error in UseMethod("vcov") : 
  no applicable method for 'vcov' applied to an object of class "list"

Should I be doing this another way?
Thanks

Danielle



More information about the R-help mailing list