Reputation: 53
I am trying to create a dashboard for a project that I am working on. In this project, I am trying to integrate a few plots from tableau.public.com using renderUI
. I want the dashboard to use selectInput
to select which tableau plot will be displayed. I have changed the URLs below so they will not work if searched.
My current code is:
plot1<-"https://public.tableau.com/views/Sheet2?:showVizHome=no&:embed=true"
plot2<-"https://public.tableau.com/views/Sheet3?:showVizHome=no&:embed=true"
fluidPage(
##### Give a Title #####
titlePanel("Tableau Visualizations"),
## Month Dropdown ##
selectInput("URL", label = "Visualization:",
choices = c(plot1,plot2), selected = plot1))
And code for displaying the Tableau pages:
renderUI({
tags$iframe(style="height:600px; width:100%; scorlling=yes", src=input$URL)
})
The code does what I want it to do, except for the the selectInput option. I would like to have the choices in the drop-down menu refer to the actual plot name (plot1
, plot2
). However, since they variable names, the actual drop-down menu has the url listed. I cannot use the following because then it doesn't recognize the choices as variables anymore:
## Month Dropdown ##
selectInput("URL", label = "Visualization:",
choices = c("plot1,"plot2"), selected = plot1))
Is there anyway I can have the names of the variables displayed, but not the url that they represent?
Thank you
Upvotes: 0
Views: 555
Reputation: 1312
You can define a vector containing the plot names and a named vector which contains the urls like this:
plot_names <- c("Plot1", "Plot2")
## Month Dropdown ##
# Use the plot names here
selectInput("plot_name", label = "Visualization:",
choices = plot_names, selected = plot_names[1]))
And then to display the urls:
urls <- c(Plot1 = "url1", Plot2 = "url2") # vector to get the urls from the names
renderUI({
tags$iframe(style="height:600px; width:100%; scorlling=yes", src=urls[input$plot_name])
})
Hope this helps.
Upvotes: 1