I wonder if it is possible to create a link to other part of Shiny app. I mean, I have one page report with Introduction
, Plot 1
and Plot 2
panel. Within Introduction
Panel I would like to add a reference to Plot 1
and Plot 2
Panel in order to see this plot immadiately, after clicking the link. It is possible?
ui.R
library(shiny)
shinyUI(
fluidPage(
fluidPage(
titlePanel("Introduction"),
column(12,
p("Lorem ipsum dolor sit amet, consectetur adipisicing elit. Proin
nibh augue, suscipit a, scelerisque sed, lacinia in, mi. Cras vel
lorem. Etiam pellentesque aliquet tellus. Phasellus pharetra nulla
ac diam. Quisque semper justo at risus. Donec venenatis, turpis vel
hendrerit interdum, dui ligula ultricies purus, sed posuere libero
dui id orci. Nam congue, pede vitae dapibus aliquet, elit magna
vulputate arcu, vel tempus metus leo non est. Etiam sit amet lectus
quis est congue mollis. Phasellus congue lacus eget neque. Phasellus
ornare, ante vitae consectetuer consequat, purus sapien ultricies
dolor, et mollis pede metus eget nisi. Praesent sodales velit quis
augue. Cras suscipit, urna at aliquam rhoncus, urna quam viverra nisi,
in interdum massa nibh nec erat."))
),
fluidPage(
titlePanel("Hello Shiny!"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
mainPanel(
plotOutput("distPlot")
)
)
),
fluidPage(
titlePanel("Hello Shiny!"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
mainPanel(
plotOutput("distPlot2")
)
)
))
)
server.R
library(shiny)
shinyServer(function(input, output) {
output$distPlot <- renderPlot({
x <- faithful[, 2] # Old Faithful Geyser data
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
output$distPlot2 <- renderPlot({
x <- faithful[, 2] # Old Faithful Geyser data
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
})
What you are looking for is an HTML anchor tag
.
You could for example create an anchor to your distPlot2 using:
column(12,p(HTML("intro text <a href='#distPlot2'>Go to plot 2</a> intro text ")))
You can replace what is after the #
by the id
any HTML element you want to jump to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With