【问题标题】:How do I size a Shiny app within an R-Markdown document using the Tufte Template?如何使用 Tufte 模板在 R-Markdown 文档中调整 Shiny 应用程序的大小?
【发布时间】:2019-05-21 12:13:12
【问题描述】:

我正在使用 R-Markdown 和 Tufte 模板编写报告。我在报告中嵌入了闪亮的应用程序。

到目前为止,我已经尝试在块选项中使用“fig.width=”和“width=”无济于事,然后尝试“,
options = list(height = 600) " 就在 B. Davis change dimensions of shiny app embedded in r markdown HTML 建议的右括号之前,同样没有变化。


hist_dist <- read.csv("hist_dist2.csv", check.names = FALSE)

inputPanel(

selectInput("dist", label = "Choose an ecosystem to explore historical disturbance regimes:", choices = hist_dist$`Ecosystem`, selected = "Northern Hardwoods Forest" ,  width = '70%')
)

renderPlotly({
        ggplot(filter(hist_dist, Ecosystem == input$dist), aes(x=Disturbance, y=Acres)) +
            geom_bar(stat="identity", fill = "darkslategrey") +
            coord_flip() +
            theme(legend.position='none') +
            expand_limits(y=c(0, 60)) +
            theme_bw() + 
            theme(panel.background = element_rect(colour = "grey", fill=NA, size=1), 
            text = element_text(family = "serif", size = 14), 
            panel.grid.major = element_blank(),
            panel.grid.minor = element_blank(), 
            axis.line = element_line(colour = "black")
)

}


)
'''


I am able to change the width if I use other templates (non-Tufte), and are able to control the size of figures, just not Shiny apps.

【问题讨论】:

    标签: templates shiny r-markdown tufte


    【解决方案1】:

    我也遇到过同样的情况。 Tufte_html 在幕后有一些覆盖宽度。

    这是我的解决方案。不是最好的,但有效。基本上你需要将 id 分配给绘图,然后从 CSS 更改样式。

    编辑 输出$my_plotly

    添加 plotlyOutput("my_plotly") 在同一个块中。

    编写styles.css

    #my_plotly ❴ width: 55% !important❵

    我相信 Tufte 风格使用了 55%。

    【讨论】:

      猜你喜欢
      • 2019-01-07
      • 2018-10-16
      • 1970-01-01
      • 2021-12-08
      • 2019-03-04
      • 2021-09-26
      • 2021-07-11
      • 2018-05-25
      • 2017-02-22
      相关资源
      最近更新 更多