R:我可以在闪亮的ui.R文件中包含R markdown文件吗? [英] R: Can I include an R markdown file in a shiny ui.R file?
问题描述
我在 http:/上参考代码示例/shiny.rstudio.com/gallery/includes-html-text-and-markdown-files.html .就我而言,我想包含和R markdown文件而不是markdown.
I refer to the code example at http://shiny.rstudio.com/gallery/including-html-text-and-markdown-files.html. In my case I would like to include and R markdown file rather than a markdown.
以下是我的ui.R代码
The following is my code for ui.R
library(markdown)
shinyUI(fluidPage(
titlePanel("Tourist expenditure for the year 2012 in Malta"),
fluidRow(
column(2,
checkboxGroupInput("id1", "Analyse by",
c("Sex" = "1",
"Age Group" = "2")
)),
column(6,
h4('You entered'),
verbatimTextOutput("oid1")
),
column(4,
includeMarkdown("intro.Rmd")
)
)
))
我的问题是当intro.Rmd嵌入ShinyUI时不会编译,但是当我选择编织HTML"选项时会按预期工作.
My problem is that intro.Rmd is not compiling when embedded in shinyUI but works as expected when I choose the Knit HTML option.
有没有一种方法可以直接插入Rmd源文件.
Is there a way I can insert the Rmd source file directly.
谢谢.
推荐答案
我过去也遇到过类似的问题,并且知道以下两种解决方案:
I've had similar problems in the past, and know of two solutions:
-
使用您提到的功能预编译.Rmd文件并包括markdown或HTML.
pre-compile the .Rmd file and include the markdown or HTML using the functions you've mentioned.
在server.R文件中从闪亮"调用knitr(如果文档由于闪亮的应用程序而发生变化),然后将包含html/markdown的已编译HTML/markdown代码与includeHTML()或类似函数一起包含.
call knitr from shiny within the server.R file (if the document changes due to the shiny app) and then include the compiled HTML/markdown code with includeHTML() or a similar function.
这篇关于R:我可以在闪亮的ui.R文件中包含R markdown文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!