rcoefplot

Facing Error with command multiplot from coefplot package in R


Is there anybody facing the same as I am when running the command multiplot from Rpackage coefplot?

Even for the example:

data(diamonds)
model1 <- lm(price ~ carat + cut, data=diamonds)
model2 <- lm(price ~ carat + cut + color, data=diamonds)
model3 <- lm(price ~ carat + color, data=diamonds)
multiplot(model1, model2, model3)

I´m now getting the below error:

Error in get(x, envir = this, inherits = inh)(this, ...) : 
attempt to apply non-function

Any hint?


Solution

  • This answer is a bit tangential, but I have found the slightly more recent combination of the broom and dotwhisker packages to be useful - broom is the back end (converting models to "tidy" data frames of coefficients) and dotwhisker is the front end (creating plots via a fairly thin ggplot2 layer)

    library(ggplot2)
    library(dotwhisker)
    library(broom)
    

    update: re-installed dotwhisker v 0.2.0.3, this appears to work:

    dwplot(list(model1,model2,model3))
    

    You can also dwplot(list(m1=model1,m2=model2,m3=model3)) if you want to pick different model names on the fly.

    Alternatively, for finer control you can construct the full data frame yourself:

    mList <- list(carat_cut=model1, carat_cut_color=model2,
                  carat_color=model3)
    library(plyr)
    ## extract tidy data frames and combine them ...
    mFrame <- ldply(mList,tidy,conf.int=TRUE,.id="model")
    

    Now you can just do

    dwplot(mFrame)