AlfredD
December 11, 2017, 10:26am
1
I have a problem with a RMD script. It runs. Once. After that, I get partial results.
The code:
---
title: "Dashboard"
output:
flexdashboard::flex_dashboard:
runtime: shiny
---
```{r global, include=FALSE}
library(dplyr)
library(flexdashboard)
Name=c('Test1', 'Test1', 'Test2')
Number = c(8, 9, 7)
zt <- data.frame(Name, Number)
PersonList <- sort(unique(zt$Name))
```
Selections {.sidebar}
===============================
```{r}
## The shiny part
selectInput("PersonSel", "Person: ", PersonList, selected = 'Test1')
```
Tab 1
======================================================================
Row {.tabset}
-----------------------------------------------------------------------
### Table
```{r}
renderTable({
cqi <- zt %>%
na.omit() %>%
filter(Name %in% input$PersonSel) %>%
group_by(Number) %>%
summarise(Count = n())
}, align='l')
```
But only this - it doesn't continue.
The only way to get it working again is to edit the script. Add a space or whatever.
Is seems very strange behavior. What can be the problem (and solution) here?
kent37
December 14, 2017, 8:29pm
2
It would help if you enclose your entire example in four backticks (````
at the beginning and end) to make it more readable and copyable.
AlfredD
December 15, 2017, 8:34am
3
Thanks, is it usable now?
kent37
December 15, 2017, 1:37pm
4
Yes, I see the same issue. Here is a smaller reprex. Running this once (in RStudio on macOS), the table draws and responds to the select input. Running it again without making any changes, the table doesn't draw. I don't know why.
---
title: "Dashboard"
output:
html_document:
runtime: shiny
---
```{r}
zt <- data.frame(Name=c('Test1', 'Test1', 'Test2'),
Number = c(8, 9, 7)
)
PersonList <- sort(unique(zt$Name))
selectInput("PersonSel", "Person: ", PersonList, selected = 'Test1')
renderTable({
zt[zt$Name %in% input$PersonSel, ]
})
```
AlfredD
December 15, 2017, 1:55pm
5
Same result here. I guess it goes wrong in the renderTable part. But why????
mine
December 15, 2017, 4:15pm
6
Reformatting the YAML as
---
title: "Dashboard"
output: html_document
runtime: shiny
---
should fix the issue.
2 Likes
AlfredD
December 15, 2017, 6:10pm
7
Hi Mine,
Thanks, it doesn't work however. Do you have other suggestions?
AlfredD
December 18, 2017, 7:47am
8
Oh I see now what you mean, Mine. 'html_document' started on a new line, and that is the problem. The problem is solved now!
1 Like
mine
December 19, 2017, 1:58am
9
Glad to hear it worked. Basically runtime
is not an option for the output type, hence should not be listed under html_document
but instead as its own entry in the YAML.