I have a Rmd file with html output. When I run rmarkdown::render_site()
I take the files generated within _site and add them to a webserver. Then, when I visit the URL everything works and I can see my analysis as an html document online.
I attempted to add a shiny code block to my analysis using the inline embed method.
When I run just this code chunk by clicking the 'run current chunk' option within the Rmd file it works in that a popup window appears and I can see my app render.
However, when I run the entire document, everything renders except the shiny part. Instead there's a grey rectangle square in the place where the shiny app was expected to appear.
I'll add information here that I think may be relevant, let me know if there's more ifnormation I should provide.
My Rmd file looks like this:
Th yml part at the top. I also have this exact same code in a separate file called _site.yml
---
title: "My Analysis"
subtitle: "Day 7 to day 365 analysis"
date: "`r Sys.Date()`"
author: "My Name"
output:
tufte::tufte_html:
toc: true
toc_collapsed: true
df_print: kable
link-citations: yes
runtime: shiny
---
Then I have several code chunks:
```{r setup, include=FALSE}
# code here
```
```{r somecode, include=FALSE}
# code here
```
Now for the chunk with inline shiny:
{r shiny_app, echo = FALSE}
library(shiny)
shinyApp(
ui = fluidPage(
# inputs
radioButtons("usa", "United States", choiceNames = c("USA", "ROW"), choiceValues = c(1, 0)),
radioButtons("fb", "Facebook Connected", choiceNames = c("Is Connected", "Not Connected"), choiceValues = c(1, 0)),
radioButtons("paid", "Paid Source", choiceNames = c("Paid", "Organic"), choiceValues = c(1, 0)),
radioButtons("returner", "Returning User", choiceNames = c("Returner", "Single Session"), choiceValues = c(1, 0)),
sliderInput("sessions", "Sessions", min = 1, max = 150, value = 30),
sliderInput("rating", "Avg Star Rating", min = 2.5, max = 5, value = 3, step = 0.1),
sliderInput("submissions", "Design Submissions", min = 0, max = 55, value = 10, step = 1),
tableOutput("predicted_rpi")
),
server = function(input, output) {
filtered_row <- reactive({
# median of spend distribution to feed into predict (one row to mutate)
user_inputs <- model_dat %>% select(matches("Dist")) %>% lapply(median) %>% unlist() %>% t() %>% data.frame() %>%
mutate(
united_states = input$usa,
facebook_connected = input$fb,
paid_source = input$paid,
returner = input$returner,
sessions = input$sessions,
avg_rating_received = input$rating,
submissions = input$submissions
) %>%
mutate_all(as.numeric) %>%
mutate(
fb_x_sessions = facebook_connected * sessions,
fb_x_united_states = facebook_connected * united_states,
avg_rating_receivedSqd = avg_rating_received^2.0,
submissionsSqd = submissions^2.0,
sessionsSqd = sessions^2.0
)
})
output$predicted_rpi = renderTable(predict(lm_model_refined_log, newdata = filtered_row()) %>% exp())
},
options = list(height = 1500)
)
Here is a screen shot of the html doc that resulted from running the code. After inspecting the area where the shiny app should be it looks like an iframe except it is empty. How can I get the shiny part to render here?
Here is the contents of _site folder after running rmarkdown::render_site()
:
I'm not sure if more files are expected to be in here?