【问题标题】:Interpreting the 'eruptions' variable option for knitr chunk in RMarkdown解释 RMarkdown 中 knitr 块的“爆发”变量选项
【发布时间】:2017-09-11 15:47:37
【问题描述】:

我有以下从 RStudio 基本 Rmarkdown-Shiny 运行时模板获得的 knitr 块:

```{r eruptions, echo=FALSE}
inputPanel(
  selectInput("n_breaks", label = "Number of bins:",
              choices = c(10, 20, 35, 50), selected = 20),

  sliderInput("bw_adjust", label = "Bandwidth adjustment:",
              min = 0.2, max = 2, value = 1, step = 0.2)
)

renderPlot({
  hist(faithful$eruptions, probability = TRUE, breaks = as.numeric(input$n_breaks),
       xlab = "Duration (minutes)", main = "Geyser eruption duration")

  dens <- density(faithful$eruptions, adjust = input$bw_adjust)
  lines(dens, col = "blue")
})
```

{r eruptions, echo=FALSE}eruptions选项有什么用

【问题讨论】:

    标签: r markdown rstudio knitr r-markdown


    【解决方案1】:

    这是块的名称。

    你不能给不同的块起相同的名字。

    【讨论】:

    • 给chunk命名的目的是什么?
    • 认为是一个标签。发生错误时,错误输出会告诉您块的名称。
    • 你也可以通过写一个没有 R 代码的块来重复一个块,但重复原始的名称。它可以有不同的选项。
    猜你喜欢
    • 2021-09-02
    • 1970-01-01
    • 2021-09-21
    • 2018-12-10
    • 2015-04-21
    • 1970-01-01
    • 2014-09-05
    • 1970-01-01
    • 2019-04-13
    相关资源
    最近更新 更多