I am working on a portfolio for my class. I am using a flex dashboard, with shiny, to showcase two shiny visualizaitons and 4 plotly charts. The first shiny app's radio button code works for both of my shiny apps, while my second shiny app's radio button code has no affect on either of the shiny applications. My professor is not super familiar with flex dashboard, so if anyone knows a solution I'd appreciate it, thanks.
This is the code for my first shiny app, this works perfectly.
Input {.sidebar}
User Input
radioButtons(
inputId = "Region",
label = "Which regions do you want to display?",
choices = c("Central America and the Caribbean","Central Europe", "East Asia", "Eastern Europe", "Middle East", "North Africa",
"North America", "Oceania", "South America", "South Asia", "South East Asia", "sub-Saharan Africa",
"Western Europe"),
)
Column
Chart 3
renderPlotly({
Region_Gov_Spending_1991 <- filter(military_data_1991, Region %in% input$Region)
ggplotly(ggplot(dat= Region_Gov_Spending_1991, aes(y=`1991 Share of Govt Spending`, x= `1991 Share of GDP`, color= Region, label=Country))+
geom_point()+
scale_size_continuous(guide = "none")+
scale_y_continuous(labels=scales::percent_format(accuracy = .01))+
scale_x_continuous(labels=scales::percent_format(accuracy = .01))+
theme_dark()+
theme(legend.text = element_text(size=8))+
theme(legend.title = element_text(size=8))+
labs(x="Percentage of GDP Spent on Military", y= 'Percentage Govt Spending on Military',
title = "GDP and Gov Spending on Military by Region in 1991")+
theme(legend.position="bottom"))
})
This is the code for my second shiny app, the radio button code from the first shiny app, affects both apps. The radio button code below has no affect on either shiny apps.
Input{.sidebar}
-------------------------------------------------------------------------------------
### User Input 2
```{r}
radioButtons(
inputId = "Region",
label = "Which regions do you want to display?",
choices = c("Central America and the Caribbean","Central Europe", "East Asia", "Eastern Europe", "Middle East", "North Africa",
"North America", "Oceania", "South America", "South Asia", "South East Asia", "sub-Saharan Africa",
"Western Europe"),
)
Column
###Chart 6
renderPlotly({
Region_Gov_Spending <- filter(military_data_2022, Region %in% input$Region)
ggplotly(ggplot(dat= Region_Gov_Spending, aes(y=`2022 Share Govt Spending`, x= `2022 Share of GDP`, color= Region, label=Country))+
geom_point()+
scale_size_continuous(guide = "none")+
scale_y_continuous(labels=scales::percent_format(accuracy = .01))+
scale_x_continuous(labels=scales::percent_format(accuracy = .01))+
theme_dark()+
theme(legend.text = element_text(size=8))+
theme(legend.title = element_text(size=8))+
labs(x="Percentage of GDP Spent on Military", y= 'Percentage Govt Spending on Military',
title = "Average GDP and Gov Spending on Military by Region in 2022")+
theme(legend.position="bottom"))
})