创建指向Shiny应用程序其他部分的链接

时间:2015-02-19 11:28:02

标签: r shiny

我想知道是否可以创建指向Shiny应用程序其他部分的链接。我的意思是,我有一个包含ItroductiionPlot 1Plot 2小组的网页报告。在Introduction小组中我想添加一个指向Plot 1和{ {1}}面板,以便在点击链接后以immadiately方式查看此图。有可能吗?

ui.R

Plot 2

server.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")
    )
  )
))
)

1 个答案:

答案 0 :(得分:6)

您要找的是HTML anchor tag。 例如,你可以使用:

为distPlot2创建一个锚点
column(12,p(HTML("intro text <a href='#distPlot2'>Go to plot 2</a> intro text "))))

您可以将#之后的id替换为您要跳转到的任何HTML元素。