I want to build an app that allows me to switch variables on a 2 discrete variables plot but i get an error when executing :
Error in parse(file, keep.source = FALSE, srcfile = src, encoding = enc) : C:\Users\HH Portable\Desktop\Dossier R\Jeux de données\Thai/ui.R:13:0: unexpected end of input 11:
mainPanel(plotOutput('plot1')) 12: ) ^ Warning: Error in sourceUTF8: Error sourcing C:\Users\HHPORT~1\AppData\Local\Temp\RtmpekudB9\fileab876054ad6 [No stack trace available]
library(shiny)
# ----- UI ----------------------------
pageWithSidebar(
headerPanel('Representer les variables'),
sidebarPanel(
selectInput('xcol', 'X Variable', names(the)),
selectInput('ycol', 'Y Variable', names(the)
),
mainPanel(plotOutput('plot1'))
)
#----- Server.r ------------------------------
library(shiny)
library(ggplot2)
# ---- Server ----------------------------------
# ---- ggplot with options ------------------------
server=shinyServer(function(input, output, session) {
output$plot1 <- renderPlot({
ggplot(the, aes(x=input$xcol, ..count..*100/sum(..count..))) +
geom_bar(aes(fill = input$ycol), position = "fill") +
geom_text(aes( label = scales::percent(..prop..),y= ..prop.. ),
stat= "count", vjust = -.5)
})
})