【问题标题】:How to change facet options with sjPlot plot_model with multiple moderators or interactions如何使用具有多个主持人或交互的 sjPlot plot_model 更改方面选项
【发布时间】:2021-03-21 05:59:17
【问题描述】:

我有一个图,我想在其中展示三个术语如何在三个不同的分类子组中相关的模型。 sjPlot::plot_model 自动创建一种在一行中包含三个图的刻面。一般来说,这很好用。但是,对于演示文稿,我还有一些其他具有四个子组的图,并且绘制在 2×2 网格中。为了使 y 轴没有显着差异,我想将 1x3 刻面更改为 2x2 刻面,其中一行上有两个图,第二行有一个图。我尝试添加 + facet_wrap() 没有成功。谁能建议一种将 1x3 plot_model 对象转换为 2x1/1x1 绘图的方法?理想情况下,仍然只有一个 x 轴标题、一个 y 轴标题和一个图例。

# example of 1x3 plot_model output
mtcars %>% 
  mutate(cyl_fct = as.factor(cyl)) %>% 
  lm(mpg ~ wt * vs * cyl_fct, data = .) %>% 
  plot_model(type = "pred", terms = c("wt", "vs", "cyl_fct"))

【问题讨论】:

    标签: r ggplot2 facet sjplot


    【解决方案1】:

    更改绘图对象内构面部分的nrow参数。

    x=mtcars %>% 
      mutate(cyl_fct = as.factor(cyl)) %>% 
      lm(mpg ~ wt * vs * cyl_fct, data = .) %>% 
      plot_model(type = "pred", terms = c("wt", "vs", "cyl_fct")) 
    
    x$facet$params$nrow=2
    
    x
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-24
      • 1970-01-01
      • 2020-01-14
      相关资源
      最近更新 更多