I have a shiny app
https://merrittr.shinyapps.io/hydroshiny/
that starts off with 2 default parameters and then below alows the user to change these parameters via a side panel. Ideally for this application I would like to link to this app from a map that would have an href and a link that would provide the app the input$z and input$y
https://merrittr.shinyapps.io/hydroshiny/?y=05EF001&z=WaterLevel
is that possible?
output$lineplot <- renderPlot({
subds <- subset(skdat, ID == input$z)
subds$datetime <- as.POSIXct(subds$Date, format = "%Y-%m-%dT%H:%M:%OS")
ggplot(subds, aes(x = datetime, y = !!as.name(input$y))) +
geom_line()
})
My other motivation is to be able to get rid of that sidebar so the graph is bigger
You'd have to update the input inside the app when initializes. You would use the session$clientData$url_search
variable to get the query parameters.
This is a simple reproducible example, that would work with this type of url https://merrittr.shinyapps.io/example-app/?bins=1
library(shiny)
ui <- fluidPage(
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
mainPanel(
plotOutput("distPlot")
)
)
)
server <- function(input, output, session) {
# Here you read the URL parameter from session$clientData$url_search
observe({
query <- parseQueryString(session$clientData$url_search)
if (!is.null(query[['bins']])) {
updateSliderInput(session, "bins", value = query[['bins']])
}
})
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
# Run the application
shinyApp(ui = ui, server = server)
You can modify this to make it work with a reactive value for example and get rid of the controls.
4 Likes
HA! that is great! thanks again Andres!
cderv
December 31, 2018, 3:20pm
4
If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:
If your question has been answered, don't forget to mark the solution!
How do I mark a solution?
Find the reply you want to mark as the solution and look for the row of small gray icons at the bottom of that reply. Click the one that looks like a box with a checkmark in it:
[image]
Hovering over the mark solution button shows the label, "Select if this reply solves the problem". If you don't see the mark solution button, try clicking the three dots button ( ••• ) to expand the full set of options.
When a solution is chosen, the icon turns green and the hover label changes to: "Unselect if this reply no longer solves the problem". Success!
[solution_reply_author]
…
system
Closed
January 7, 2019, 3:20pm
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.