r - How to extract dependent variable names from for-looped glms object to use as titles -


i making barplots of corresponding model coefficients derrived lapply function applied for-looped multi-glm object. take lwanimovesubdat data set makes facile explication in code below:

models.lw <- list()  ivnames.lw <- paste(names(subset(lwanimovsubdat[,c(1:6)], select = -c(4))),                      collapse = ' + ') dvnames.lw <- paste(names(lwanimovsubdat[7:17]), sep = ',')   (y in dvnames.lw){   form <- as.formula(paste(y, "~", ivnames.lw))   models.lw[[y]] <- glm(form, data = lwanimovsubdat)  }  (var in models.lw) {   dev.new()   barplot(coef(var)) } 

how add titles above barplots without getting things messed up. tried following , not work:

main = names(models.lw) 

please help!

main = names(models.lw) doesn't work because refers names of of models. if change barplot code follows, iterate through names of models , reference models based on names, should work.

for (var in names(models.lw)){    dev.new()    barplot(coef(models.lw[var][[1]]), main = var) } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -