I am building a Shiny and the end result will be a graph with "Depth" on the x-axis and "Values" on the y-axis. The user will upload their own dataframe so I have included two inputs that will change based on the dataframe. There is a checkboxGroupInput("elements", label = "Select Elements", choices = NULL) and then there is selectInput("depth_col", "Depth Column:", choices = NULL) and both of these have choices fed by the same observeEvent in my server.R to read the column names of the uploaded dataframe. My problem comes when I try to plot this. In my test dataset, I know the "Depth" column is actually called Depth so:
output$Gamma <- renderPlot({
input$slice
if(input$slice == 0){
return()
}
inFile <- inFile()
Element <- input$elements
inFile %>%
select(c(Depth, all_of(Element))) %>%
pivot_longer(-Depth, names_to = "Elements", values_to = "Values") %>%
ggplot(aes(x = Depth, y = Values, colour = Elements)) +
geom_path()
})
produces the desired plot (input$slice is the result of clicking the "Select" button.

Notice that it is only producing lines for the two selected elements. However, when I try to adjust the code to use input$depth_col (maybe in a different dataset the "Depth" column is called Deep, for example):
output$Gamma <- renderPlot({
input$slice
if(input$slice == 0){
return()
}
inFile <- inFile()
Deep <- input$depth_col
Element <- input$elements
inFile %>%
select(c(Deep, all_of(Element))) %>%
pivot_longer(-Deep, names_to = "Elements", values_to = "Values") %>%
ggplot(aes(x = Deep, y = Values, colour = Elements)) +
geom_path()
})
it is treating Deep as a character instead of reading the values in the column and plotting a straight line.

Essentially, the value chosen in the "Depth Column" should be assigned to the x-axis and the "Select Elements" on the y-axis. The other two inputs will be used later on but shouldn't have any bearing at this point.
Thank you to anyone who can show me where I'm going wrong here, Jeremy