【问题标题】:How to keep forest plot from getting cut off?如何防止林地被砍伐?
【发布时间】:2021-12-22 12:25:35
【问题描述】:

我正在创建几个森林地块,但它们都被切断了 RMD。可重现的例子:

author = c("aaaaaaaaaa", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "t", "u", "v", "w", "x")
Ne = c(1, 2, 3, 4, 5, 6, 7, 8, 8, 34, 5, 6, 7, 8, 4, 3, 2, 7, 3, 6, 7, 8, 5)
Me = c(1, 2, 3, 4, 5, 6, 7, 8, 8, 34, 5, 6, 7, 8, 4, 3, 2, 7, 3, 6, 7, 8, 5)
SDe = c(1, 2, 3, 4, 5, 6, 7, 8, 8, 34, 5, 6, 7, 8, 4, 3, 2, 7, 3, 6, 7, 8, 5)
Nc = c(1, 2, 3, 4, 5, 6, 7, 8, 8, 34, 5, 6, 7, 8, 4, 3, 2, 7, 3, 6, 7, 8, 5)
Mc = c(1, 2, 3, 4, 5, 6, 7, 8, 8, 34, 5, 6, 7, 8, 4, 3, 2, 7, 3, 6, 7, 8, 5)
SDc = c(1, 2, 3, 4, 5, 6, 7, 8, 8, 34, 5, 6, 7, 8, 4, 3, 2, 7, 3, 6, 7, 8, 5)

df = data.frame(author, Ne, Me, SDe, Nc, Mc, SDc)

m.cont <- meta::metacont(n.e = Ne,
                   mean.e = Me,
                   sd.e = SDe,
                   n.c = Nc,
                   mean.c = Mc,
                   sd.c = SDc,
                   studlab = author,
                   data = df,
                   sm = "SMD",
                   method.smd = "Hedges",
                   fixed = FALSE,
                   random = TRUE,
                   method.tau = "REML",
                   hakn = TRUE,
                   title = "Example")

meta::forest.meta(m.cont, 
            sortvar = TE,
            predict = TRUE, 
            print.tau2 = FALSE,
            leftlabs = c("Author", "g", "SE"),
            xlim = "symmetric")

我知道我可以通过运行块获得完整的图形,而无需编织然后扩展图形,但我希望这些图可以在 knit html 文档中呈现。

【问题讨论】:

    标签: r plot


    【解决方案1】:

    只需在块头中指定图形的宽度和高度。

    ---
    title: "Testing"
    output: html_document
    ---
    
    ```{r,fig.width = 10,fig.height=10}
    #above this is where you can add dimensions
    author = c("aaaaaaaaaa", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "t", "u", "v", "w", "x")
    Ne = c(1, 2, 3, 4, 5, 6, 7, 8, 8, 34, 5, 6, 7, 8, 4, 3, 2, 7, 3, 6, 7, 8, 5)
    Me = c(1, 2, 3, 4, 5, 6, 7, 8, 8, 34, 5, 6, 7, 8, 4, 3, 2, 7, 3, 6, 7, 8, 5)
    SDe = c(1, 2, 3, 4, 5, 6, 7, 8, 8, 34, 5, 6, 7, 8, 4, 3, 2, 7, 3, 6, 7, 8, 5)
    Nc = c(1, 2, 3, 4, 5, 6, 7, 8, 8, 34, 5, 6, 7, 8, 4, 3, 2, 7, 3, 6, 7, 8, 5)
    Mc = c(1, 2, 3, 4, 5, 6, 7, 8, 8, 34, 5, 6, 7, 8, 4, 3, 2, 7, 3, 6, 7, 8, 5)
    SDc = c(1, 2, 3, 4, 5, 6, 7, 8, 8, 34, 5, 6, 7, 8, 4, 3, 2, 7, 3, 6, 7, 8, 5)
    
    df = data.frame(author, Ne, Me, SDe, Nc, Mc, SDc)
    
    m.cont <- meta::metacont(n.e = Ne,
                             mean.e = Me,
                             sd.e = SDe,
                             n.c = Nc,
                             mean.c = Mc,
                             sd.c = SDc,
                             studlab = author,
                             data = df,
                             sm = "SMD",
                             method.smd = "Hedges",
                             fixed = FALSE,
                             random = TRUE,
                             method.tau = "REML",
                             hakn = TRUE,
                             title = "Example")
    
    meta::forest.meta(m.cont, 
                      sortvar = TE,
                      predict = TRUE, 
                      print.tau2 = FALSE,
                      leftlabs = c("Author", "g", "SE"),
                      xlim = "symmetric",)
    
    ```
    

    当你编织它时,你应该得到:

    【讨论】:

    • 完美!谢谢,我用的是 fig_width,现在 fig.width 可以用了。
    • 很高兴为您提供帮助!如果您认为这回答了问题,您可以通过单击赞成票的绿色复选标记将其标记为“已回答”。这会将其从未回答的问题组中剔除(并感谢我的回答)。
    猜你喜欢
    • 1970-01-01
    • 2019-12-06
    • 1970-01-01
    • 2012-01-02
    • 1970-01-01
    • 2020-11-16
    • 2014-10-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多