针织markdown文件有闪亮的内容

栏目: R语言 · 发布时间: 6年前

内容简介:翻译自:https://stackoverflow.com/questions/50907448/knitting-markdown-file-having-shiny-content

我创建了一个包含一些闪亮内容的markdown文件.当我运行当前的块代码时,应用程序工作得很好.但是,当我尝试编织代码块时,它会给出以下错误:

Shiny applications not supported in static R Markdown documents.

无论如何,我可以编织这个代码.

在某些网站上我也读到了以下内容

``{r, echo=FALSE}
library(shiny)
shinyAppDir(
  system.file("examples/06_tabsets", package = "shiny"),
  options = list(
    width = "100%", height = 550
  )
)
```

但是,当我编织这个时,同样的事情发生了.有没有办法从闪亮的应用程序中获取html输出.

要添加闪亮的交互,请在YAML中添加runtime:shiny.

有关如何在文档中嵌入闪亮的应用程序,请参阅 link .

请参阅在Rstudio中创建新Markdown文件时给出的标准示例(文件>新文件> R markdown> Shiny文档):

--- 
title: "Untitled" 
author: "author" 
date: "July 24, 2018" 
output: html_document runtime: shiny
---

{r setup,include = FALSE} knitr :: opts_chunk $set(echo = TRUE)

This R Markdown document is made interactive using Shiny. Unlike the more traditional workflow of creating static reports, you can now create documents that allow your readers to change the assumptions underlying your analysis and see the results immediately. 

To learn more, see [Interactive Documents](http://rmarkdown.rstudio.com/authoring_shiny.html).

## Inputs and Outputs


    ```{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")
})
```

## Embedded Application

Its also possible to embed an entire Shiny application within an R Markdown document using the `shinyAppDir` function. This example embeds a Shiny application located in another directory:

```{r tabsets, echo=FALSE} 
shinyAppDir(
system.file("examples/06_tabsets", package = "shiny"),   
options = list(width = "100%", height = 550   ) 
) 
```

Note the use of the `height` parameter to determine how much vertical space the embedded application should occupy.

You can also use the `shinyApp` function to define an application inline rather then in an external directory.

In all of R code chunks above the `echo = FALSE` attribute is used. This is to prevent the R code within the chunk from rendering in the document alongside the Shiny components.

翻译自:https://stackoverflow.com/questions/50907448/knitting-markdown-file-having-shiny-content


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

程式之美-微軟技術面試心得

程式之美-微軟技術面試心得

編程之美小 / 悅知文化 / 2008.06.20 / 490元

書內容分為以下幾個部分: ▓ 遊戲之樂:從遊戲和其他有趣問題出發,化繁為簡,分析總結。 ▓ 數字之魅:程式設計的過程實際上就是和數字及字元打交道的過程。這一部分收集了一些這方面的有趣探討。 ▓ 結構之法:彙集了常見的對字串、鏈表、佇列,以及樹進行操作的題目。 ▓ 數學之趣:列舉了一些不需要寫具體程式的數學問題,鍛煉讀者的抽象思考能力。 ▓ 書中絕大部分題目都提供了詳細......一起来看看 《程式之美-微軟技術面試心得》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具