.Hello all,
I wish to create shiny app with few tabs and I actually did it, however there are no plots on the tabs.
I read some articles to solve this problem, and I created different plots to be shown, but it didn't help. Plots are using information from the same data.table.
Could somebody look at this and tell me what and where is the problem?
Thanks in advance.
Data is generated from csv file.
ui1 <- fluidPage(navbarPage("Polish people", tabPanel('Climate change',
pageWithSidebar(
# Application title
titlePanel("What do we think about climate change?"),
sidebarPanel(
selectInput("variable", "Question:",
list("How often do you do things to reduce energy use?" = "rdcenr",
"How much electricity should be generated from coal?" = "elgcoal",
"How much electricity should be generated from natural gas?" = "elgngas",
"How much electricity should be generated from hydroelectric power?" = "elghydr",
"How much electricity should be generated from nuclear power?" = "elgnuc",
"How much electricity should be generated from solar power?" = "elgsun",
"How much electricity should be generated from wind?" = "elgwind",
"How much electricity should be generated from biomas?" = "elgbio",
"How much are you worried about power cuts?" = "wrpwrct",
"Do you think world's climate is changing?" = "clmchng",
"What is climate change caused by?" = "ccnthum",
"To what extent do you feel personal responsibility to reduce climate change?" = "ccrdprs",
"How are you worried about climate change?" = "wrclmch",
"Climate change has good or bad impact across world?" = "ccgdbd"),
selected = "ccgdbd"),
radioButtons("dist", "Distribution type:",
c("Dodge" = "dodge",
"Fill" = "fill",
"Stack" = 'stack')),
selectInput("var", "Variable2:",
list("Gender" = 'gender',
"Age" = "age1",
"European Union" = "eu",
"Children" = "children"),
selected = "eu")),
mainPanel(
h3(textOutput("caption")),
plotOutput("MeTooPlot"))
)
),
tabPanel('Life satisfaction',
fluidRow(pageWithSidebar(titlePanel("Are polish people satisfied with their lives?"),
sidebarPanel(
selectInput("variable2", "Question:",
list("How satisfied are you with your life? " = "stflife",
"How satisfied are you with present state of the country's economy?" = "stfeco",
"How satisfied are you with government?" = "stfgov",
"How satisfied are you with the way democracy works in country?" = "stfdemo",
"How satisfied are you with the state of health service? " = "stfhlth",
"Men should have more right to job than women when jobs are scarce" = "mnrgtjb",
"How happy are you?" = "happy"),
selected = "stflife"),
radioButtons("dist2", "Distribution type:",
c("Dodge" = "dodge",
"Fill" = "fill",
"Stack" = 'stack')),
selectInput("var2", "Variable2:",
list("Gender" = 'gender',
"Age" = "age1",
"European Union" = "eu",
"Children" = "children"),
selected = "eu")),
mainPanel(
h3(textOutput("caption")),
fluidRow(plotOutput("MeTooPlot2")))
))),
tabPanel('Other',fluidRow(
pageWithSidebar( mainPanel(
plotOutput("MeTooPlot3")),
# Application title
titlePanel("What poles think?"),
sidebarPanel(
selectInput("variable3", "Question:",
list("Watching, reading or listening to news about politics (in minutes)" = 'news',
"How often do you use Internet?" = "internet",
"Can you trust others?" = "trust",
"Are you interested in politics?" = "polintr",
"Which party did you vote last selection?" = "party",
"Men should have more right to job than women when jobs are scarce" = "mnrgtjb",
"Gays and lesbians free to live life as they wish" = "freehms",
"Immigration is good or bad for the economy" = "imbgeco",
"Countr's cultural life is undermined or enriched by immigrants?" = "imueclt",
"Immigrants make country worse or better place to live?" = "imwbcnt",
"How religious are you?" = "rlgdgr"),
selected = "internet"),
radioButtons("dist3", "Distribution type:",
c("Dodge" = "dodge",
"Fill" = "fill",
"Stack" = 'stack')),
selectInput("var3", "Variable2:",
list("Gender" = 'gender',
"Age" = "age1",
"European Union" = "eu",
"Children" = "children"),
selected = "age1"))
)
)
))
)
server1 = function(input, output) {
formulaText <- reactive({
paste("Answers: ", input$variable)
})
output$caption <- renderText({
formulaText()
})
output$MeTooPlot <- renderPlot({
p <- ggplot(dane)
p + geom_bar(aes(x=dane[,input$variable], fill=factor(dane[,input$var])),
color="black",
position=input$dist)
})
output$MeTooPlot2 <- renderPlot({
p <- ggplot(dane)
p + geom_bar(aes(x=dane[,input$variable2], fill=factor(dane[,input$var2])),
color="black",
position=input$dist2)
})
output$MeTooPlot3 <- renderPlot({
p <- ggplot(dane)
p + geom_bar(aes(x=dane[,input$variable3], fill=factor(dane[,input$var3])),
color="black",
position=input$dist3)
})
}
shinyApp(ui1, server1)