Shiny, flexdashboard and databases issue: app only functions once

My brain hurts:

I've built a simple flexdashboard that fetches data from a database.
It runs fine the first time. When I run the app again the data is no longer fetched.
I can then change the name of a variable in the document, save it, and then it runs fine again ...
but only the first time.

I simply do not understand what is going on under the flexdashboard hood and would appreciate any insights.
I fear that there is some important house keeping that I fail to do.

I run:

R version 3.4.3 (2017-11-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS

other attached packages:
[1] pool_0.1.4 dplyr_0.7.4 purrr_0.2.4 readr_1.1.1 tidyr_0.7.1 tibble_1.4.2
[7] ggplot2_2.2.1.9000 tidyverse_1.1.1 flexdashboard_0.5.1

shiny-server - Shiny Server v1.5.6.875 (Node.js v6.10.3)

Below is a minimal example that replicates the issue on my machine.

	---
	title: "flex_dashboard"
	output: 
	  flexdashboard::flex_dashboard:
		orientation: columns
		vertical_layout: fill
		runtime: shiny
	---

	```{r setup, include=FALSE}
	library(tidyverse)
	library(pool)
	```

	```{r}
	con <- dbPool(
	  drv = RMySQL::MySQL(),
	  dbname = "shinydemo",
	  host = "shiny-demo.csa7qlmguqrf.us-east-1.rds.amazonaws.com",
	  username = "guest",
	  password = "guest"
	  )
	```

	```{r}
	tbl_gps <- reactive({

	  dplyr::tbl(con, dplyr::sql("SELECT * FROM City")) %>% 
		dplyr::collect()
	  
	})
	```

	Column {.tabset .tabset-fade}
	-----------------------------------------------------------------------

	### Table

	```{r dice}
	DT::dataTableOutput("sliced")
	output$sliced <- DT::renderDataTable(tbl_gps(), filter = c("bottom"))
	```

I don't think the app is recognising the runtime: shiny part of the yaml because it is indented. try un-indenting so that it sits in-line with the title and output parts

3 Likes

That did it!

You are a super hero - what a stupid error - I could have spend forever looking in all the wrong places to figure out what was happening!

Thanks!

1 Like

Glad to hear you're up and running. Could you please mark the solution to your question?

1 Like