First of a small disclaimer: This is my first ever asked question and I am not very experienced with shiny or "R" since this is only for a small project :)
How it is:
I made histograms that show the same data in percentages and quantity. Currently its looking like this:
The current state of my histograms
What I am trying to do now:
Instead of having 2 histograms vertically I want an input that lets me choose, if I want the data to be shown in percentages or quantities.
I want to add text next to the histogram to describe the data
I want them to align horizontally like this: INPUT - HISTOGRAM - TEXT
How my code is looking up to this point:
ui <- fluidPage(
theme = bs_theme(version = 4, bootswatch = "minty"),
titlePanel("Titanic"),
sidebarLayout(
sidebarPanel(),
mainPanel(
img(src = "titanicPic.jpg",height = 182, width = 520))),
p(""),
h4("", style = "font-family: 'times';,font-si16pt"),
h6("", style = "font-family: 'times';,font-si16pt"),
h6("", style = "font-family: 'times';,font-si16pt"),
tabsetPanel(
tabPanel("x", tableOutput("")),
tabPanel("y", verbatimTextOutput("")),
tabPanel("z", tableOutput(""))),
plotOutput(outputId = "ex1", width = 400),
plotOutput(outputId = "ex2", width = 400)
server <- function(input, output) {
output$ex1 <- renderPlot({
ggplot( survivalMutate,
aes(x = Sex, fill = Status)) +
ggtitle("Wer hat überlebt in %?")+
geom_bar(position = "fill")+
scale_fill_manual(values = c("grey24", "snow")) +
labs(y= "Proportion")
})
output$ex2 <- renderPlot({
ggplot(survivalMutate,
aes(x = Sex,
fill = Status)) +
geom_bar(position = "stack") +
ggtitle("Wer hat überlebt in anzahl?")+
scale_fill_manual(values = c("grey24", "snow"))+
labs(y= "Anzahl")
})
shinyApp(ui = ui, server = server)
In ui you can see in the last two rows that im making the plotOutputs for the two histograms, that I created in the server-part. These take the same data but differ in how they show it (Percentages vs. quantities).
I'd be super thankful for any advice, links to look it up, tips and more. Thank you a lot If you've read to this point and have a nice day/evening/night!