I am learning flexdashboard, but I dont have clear the structure.
I have created a sample dataset to plot in a dashboard a barplot according to the selected variable.
The code is the next:
---
title: "flexdashboard: Shiny Embedding"
output:
flexdashboard::flex_dashboard:
social: menu
source_code: embed
runtime: shiny
---
```{r global, include=FALSE}
library(tidyverse)
## generate a sample dataset
sample<-tbl_df(data.frame(c("City1","City2","City3","City1","City2","City3",
"City2","City3"),
c("A","B","C","D","D","A","A","B"),
c(12,14,15,12,12,14,8,10)))
colnames(sample)<-c("City","Country","Amount")
df<-
reactive(sample%>%group_by(input$variable)%>%summarise(total=sum(Amount)))
```
Column {.sidebar}
-------------------------------------------
```{r}
selectInput(inputId="variable",label="group by",choices=c("City","Country"))
```
Column
------------------------------------------
### Plot
```{r}
renderPlot({barplot(total)})
```
But, I can´t get what I need.
Some suggestions or help?