I have the following code:
library(jtools)
v1 <- rbinom(100, size=1, p=0.5)
v2 <- rnorm(1:100)
v3 <- rnorm(1:100)
v4<- rbinom(100, size=1, p=0.5)
mydf<- data.frame(v1, v2, v3, v4)
analysis1 <- glm(v1 ~ v2 v3 v4 )
analysis2 <- glm(v2 ~ v1 v3 v4 )
plot_summs(analysis1, analysis2, model.names = c("1", "2"))
And it produces a plot like this:
I want to change the label "Model" in the legend to "Type." I was wondering if it is possible.
CodePudding user response:
Yes (almost) everything is possible!
library(jtools) gives rather customized ggplot (S3) object back so default ggplot tricks like changing
p$label
won't work, however, luckily Jacob (the author) provides you with an optional argument:
plot_summs(analysis1, analysis2, model.names = c("1", "2"),legend.title = "Type")
which changes the legend title as expected.
bonus hint :
Please feel free to read more about the packages you are using on https://cran.r-project.org/web/packages/jtools/jtools.pdf or by typing :
> ??jtools::plot_summs