【问题标题】:par(mfrow = c(x, y)) not working in Rmd inline outputpar(mfrow = c(x, y)) 在 Rmd 内联输出中不起作用
【发布时间】:2020-02-10 17:59:11
【问题描述】:

我开始在 Rmd 中工作,因为我更喜欢它在块之后输出到 R 脚本的控制台。

par(mfrow = c(x, y)) 但是不适用于内联输出。所以一个带有

的R块

par(mfrow = c(x, y)) boxplot() boxplot()

等等。不显示多个图。 boxplot() 是基础 R。

是否有资源解释原因?

【问题讨论】:

    标签: r r-markdown boxplot


    【解决方案1】:

    par(mfrow = c(x, y)) 中的 x 和 y 表示行和列,而不是图。你想要这样的东西:

    set.seed(123)
    mat <- matrix(sample(120:200,200,TRUE), ncol=10, nrow=20)
    par(mfrow=c(1,2))
    boxplot(x = list(mat[,1], y = mat[,2]))
    boxplot(x = list(mat[,3], y = mat[,4]))
    

    par(mfrow=c(1,1))
    ``
    

    【讨论】:

    • 抱歉,我的问题有误。有关问题,请参见上文。
    • 如果您定义了自己的不使用base 图形的箱线图函数,那么您可能必须使用cowplot::plot_grid(用于ggplot2 对象)或grid 图形的视口。
    • 另请参阅stackoverflow.com/questions/37115276/… 了解可能有帮助的块选项。
    • boxplot() 是基础 R。而且我不是在编织,所以块选项不应该对 AFAIK 产生影响。
    猜你喜欢
    • 2022-11-21
    • 1970-01-01
    • 2013-11-10
    • 2021-12-10
    • 1970-01-01
    • 2011-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多