Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201919

Is it possible to render a "runtime:shiny" rmarkdown (.rmd) file, using an action button, in a shiny app?

$
0
0

Let's say we have this "runtime: shiny" RMD file I built on RStudio. It has 4 main parts:


    ---
    title: "Theory"
    output: html_document
    runtime: shiny
    ---

    Part 1: html code
    <style type="text/css">

    h1.title {

    text-align: center;
    color: DarkBlue;
    font-size: 38px;

    }

    p{

    font-size: 18pt;
    font-family: times, serif;
    }
    </style>


    <br>
    </br>

    ---

    Part2: Inline equations

    <p>
    This is an inline equation: $y = \frac{a}{b}$
    </p>

    <br>
    </br>

    ---

    Part3: Standalone equations

    $$y = \frac{a}{b} $$

    <br>
    </br>

    ---

    Part4: Embedded shiny 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")
    })

I can "Run Document" that in rStudio and it works perfectly.

Now I save that .rmd file and then reference it later while building my shiny app:


    ui <- shinyUI(
        fluidPage(
            withMathJax(includeMarkdown("ShinyRMarkdownFile.rmd"))
      )
    )
    server <- function(input, output) { }

    shinyApp(ui, server)

When I run the app, it fails to successfully display all 4 parts of the "runtime: shiny" rmd file other than the text itself. The reason I am asking is because I eventually want to build an action button that, when clicked, will display the "runtime: shiny" rmd file.

Is it not possible to render "runtime: shiny" rmd files because they they are incompatible with the shiny app format?

P.S. I can mostly solve this problem by converting the rmd to an html IF part 4 (the "Embedded shiny inputs and outputs") is removed (otherwise I get an error). But I want to keep that if possible. Would make my life much easier.


Viewing all articles
Browse latest Browse all 201919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>