R: Can I include the R markup file in the shiny ui.R file?

I am linking to the sample code at http://shiny.rstudio.com/gallery/including-html-text-and-markdown-files.html . In my case, I would like to include both the R markdown file and not the markdown.

Below 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")
        )
    )
))

      

My problem is that intro.Rmd does not compile when embedded in shinyUI, but works as expected when I select the Knit HTML option.

Is there any way to insert the original Rmd file directly.

Thank.

+3


source to share


1 answer


I have had similar problems in the past and know two solutions:



  • precompile the .Rmd file and include markdown or HTML using the specified functions.

  • call knitr from the shiny server.R file (in case the document changes due to the shiny app) and then include the compiled HTML / markdown code with includeHTML () or similar function.

+6


source







All Articles