Multiple select input to plot line graph or scatter plot

Hi, I am new to R and I am trying to make a dashboard using flex dashboard.I am making a dashboard where a user can select 1 x variable and potentially multiple y variables. I have radio buttons set up for my x inputs and a checkbox input for my y inputs. Right now I am able to plot 1 x variable and 1 y variable. I want my code to essentially update with the different user inputs.

radioButtons(
  "x", 
  h3("X Variable"),
  choices = c("date"="Timestamp.Excel_1900.","temperature [C]"= "Temperature.C.", "conductivity [µS/cm]"="Conductivity.uS.cm.","turbidity [NTU]"="Turbidity.NTU.","salinity [PSU]"= "Salinity.psu." ))

checkboxGroupInput(
  'y', 
  h3("Y Variables"), 
  choices= c("cellpres [kPa]"="Cellpres.kPa.", "raw co2"="Raw_co2.NA.", "h2o [ppt]"="H2o.ppt.", "temperature [C]"="Temperature.C.", "conductivity [µS/cm]"="Conductivity.uS.cm.", "pressure [dbar]"="Pressure.decibar.", "oxygen [µg/L]"="Oxygen.umol.l.", "pH [pH]"="pH.pH.","Chlorophyll [µg/L]"="Chlorophyll.ug.l.", "turbidity [NTU]"= "Turbidity.NTU.", "chlorophyll STD* [µg/L]"="Chlorophyll_STD.ug.l.", "turbidity STD* [NTU]"="Turbidity_STD.NTU.", "salinity [PSU]"="Salinity.psu.", "Sound Velocity [m/s]"="Sound_Velocity.m.s.", "Spec. conductivity [µS/cm]"="Spec_Conductivity.uS.cm", "oxygen saturation"="Oxygen_Saturation...", "co2 [ppm]"="Co2.ppm.","co2 absorptance"="Co2abs.absorptance.", "h2o absorptance"="H2oabs.absorptance.", "h20 dew point [C]"="H2odewpoint.C.", "ivolt [V]"="ivolt.V.", "raw co2 ref"="Raw_co2ref.NA.","raw h2o"="Raw_h2o.NA.")
  )

output$scatter <-renderPlotly({


  cat('input$x=',input$x,'\n')
   p <- ggplot(Merged_data_frame_hcat, aes_string(x=input$x, y=input$y)) +
       geom_point()+
       theme_minimal(base_size = 14)
   g <- ggplotly(p, source = 'source') %>%
    layout(dragmode = 'lasso',
           margin = list(l = 100),
           font = list(family = 'Open Sans', size = 16))


})

plotlyOutput('scatter', width = "80%")

I tried using a loop where I would create each graph and then stored them in a list to be printed of later. However, that has not worked well.In the future I also want users to have a choice between displaying all the variables together or having multiple graphs with the same x variable but the individual y variables.

data_plots <- 
    map_list <- list()
    for (i in 1:length(input$y)){
        print(input$y)

        cat('input$x=',input$x,'\n')
        p <- ggplot(Merged_data_frame_hcat, aes_string(x=input$x, y=input$y[i])) +
        geom_point()+
        theme_minimal(base_size = 14)
        g <- ggplotly(p, source = 'source') %>%
            layout(dragmode = 'lasso',
            margin = list(l = 100),
           font = list(family = 'Open Sans', size = 16))
        map_list[[i]] <-g
    
}