Challenge
I am looking to design a user interface with multiple sliders, a plot output, and radio buttons. The sliders allow users to choose values, while the radio buttons determine which slider's value is reflected in the plot.
Ideally, I want each slider to have an individual radio button placed in front of it (without any labels) instead of using a radio button group. How can I achieve this? Would some adjustments in the CSS
be necessary? I have previously worked on a similar concept with checkboxes (not as a checkbox group), utilizing columns. However, I believe that radio buttons would be more suitable here since I intend to restrict users to selecting only one element.
Current Setup
(Radiobutton 1)
(Radiobutton 2)
[----Slider 1----]
[----Slider 2----]
Preferred Layout
(Radiobutton 1) [----Slider 1----]
(Radiobutton 2) [----Slider 2----]
Sample Code
library(shiny)
app <- shinyApp(
ui = bootstrapPage(
radioButtons("slds.rb", label = "", choices = paste0("sld", 1:2)),
sliderInput("sld1", min = 0, max = 10, label = "y1", value = 5),
sliderInput("sld2", min = 0, max = 10, label = "y2", value = 5),
plotOutput('plot')
),
server = function(input, output) {
output$plot <- renderPlot({
plot(seq_len(input[[input$slds.rb]]))
})
})
runApp(app)