R 不同标签间的闪亮导游之旅
我想知道是否可以使用cicerone包创建一个跨多个选项卡的导游,从位于“About”选项卡上的导游按钮开始,如下面的脚本所示。到目前为止,我只能在一个选项卡上进行巡演。然而,我被要求使用一个教程来显示闪亮应用程序不同选项卡上的绘图之间的连接 如果导游不是答案,有人能提出一个好的替代方案吗 顺便说一句,我没有足够的声誉创建一个导游标签。如果有人愿意,那就太好了R 不同标签间的闪亮导游之旅,r,shiny,R,Shiny,我想知道是否可以使用cicerone包创建一个跨多个选项卡的导游,从位于“About”选项卡上的导游按钮开始,如下面的脚本所示。到目前为止,我只能在一个选项卡上进行巡演。然而,我被要求使用一个教程来显示闪亮应用程序不同选项卡上的绘图之间的连接 如果导游不是答案,有人能提出一个好的替代方案吗 顺便说一句,我没有足够的声誉创建一个导游标签。如果有人愿意,那就太好了 library(shiny) library(cicerone) #Cicerone guide guide <- Cice
library(shiny)
library(cicerone)
#Cicerone guide
guide <- Cicerone$
new(allow_close = FALSE)$
step(
"nobs1",
"Observations",
"Number of observations to draw distribution for plot 1"
)$
step(
"submit_button1",
"Submit Data",
"Hit the button after you've set the number of observations for the first plot"
)$
step(
"hist1",
"Histogram",
"The first histogram appears here."
)$
step(
"nobs2",
"Observations",
"Number of observations to draw distribution for plot 1"
)$
step(
"submit_button2",
"Submit Data",
"Hit the button after you've set the number of observations for the second plot"
)$
step(
"hist2",
"Histogram",
"The second histogram appears here."
)
#####################################
#UI
ui <-
shinyUI(
navbarPage("One tour with Cicerone across different tabs",
###########################
tabPanel("About",
"In this app you can input data and try out different plots.",
tags$br(),
tags$br(),
"If you need help, take the tour below.",
tags$br(),
tags$br(),
use_cicerone(),
actionButton("guide", "Take the tour")
),
###########################
########################################################
tabPanel("Plots",
#######################################
tabsetPanel(
tabPanel("Plot 1",
sidebarPanel(
numericInput("nobs1", "Observations", min = 50, max = 200, value = 20),
actionButton("submit_button1", "Submit observations")
),
mainPanel(
plotOutput("hist1")
)
), #closes tab panel Plot 1
tabPanel("Plot 2",
sidebarPanel(
numericInput("nobs2", "Observations", min = 50, max = 200, value = 20),
actionButton("submit_button2", "Submit observations")
),
mainPanel(
plotOutput("hist2")
)
) #closes tab panel Plot 2
)#closes tabset panel
)#closes tab panel
) #closes navBarPage
) #closes shinyUI
#####################################
#SERVER
server <- function(input, output){
guide$
init()$
start()
dat1 <- eventReactive(input$submit_button1, {
runif(input$nobs1)
})
dat2 <- eventReactive(input$submit_button2, {
runif(input$nobs2)
})
output$hist1 <- renderPlot({
hist(dat1())
})
output$hist2 <- renderPlot({
hist(dat2())
})
observeEvent(input$guide, {
guide$start()
})
}
shinyApp(ui, server)
库(闪亮)
图书馆(导游)
#导游指南
你应该提交你自己的答案。这将有助于跟踪社区哪些问题仍然没有答案:)顺便说一句,你的帖子帮助了我,谢谢。
#New guide
#Cicerone guide
guide <- Cicerone$
new()$
step(
"[data-value='Plots']",
"Plots",
"Click on the Plots tab to see available plots",
is_id = FALSE
)$
step(
"nobs1",
"Observations",
"Number of observations to draw distribution for plot 1"
)$
step(
"submit_button1",
"Submit Data",
"Hit the button after you've set the number of observations for the first plot"
)$
step(
"hist1",
"Histogram",
"The first histogram appears here."
)$
step(
"[data-value='Plot 2']",
"Plot 2",
"Click on the Plot 2 tab to try the next plot",
is_id = FALSE
)$
step(
"nobs2",
"Observations",
"Number of observations to draw distribution for plot 2"
)$
step(
"submit_button2",
"Submit Data",
"Hit the button after you've set the number of observations for the second plot"
)$
step(
"hist2",
"Histogram",
"The second histogram appears here."
)
library(shiny)
library(cicerone)
#Cicerone guide
guide <- Cicerone$
new()$
step(
"[data-value='Plots']",
"Plots",
"Click on the Plots tab to see available plots",
is_id = FALSE
)$
step(
"nobs1",
"Observations",
"Number of observations to draw distribution for plot 1"
)$
step(
"submit_button1",
"Submit Data",
"Hit the button after you've set the number of observations for the first plot"
)$
step(
"hist1",
"Histogram",
"The first histogram appears here."
)$
step(
"[data-value='Plot 2']",
"Plot 2",
"Click on the Plot 2 tab to try the next plot",
is_id = FALSE
)$
step(
"nobs2",
"Observations",
"Number of observations to draw distribution for plot 2"
)$
step(
"submit_button2",
"Submit Data",
"Hit the button after you've set the number of observations for the second plot"
)$
step(
"hist2",
"Histogram",
"The second histogram appears here."
)
#####################################
#UI
ui <-
shinyUI(
navbarPage("One tour with Cicerone across different tabs",
###########################
tabPanel("About",
"In this app you can input data and try out different plots.",
tags$br(),
tags$br(),
"If you need help, take the tour below.",
tags$br(),
tags$br(),
use_cicerone(),
actionButton("guide", "Take the tour")
),
###########################
########################################################
tabPanel("Plots",
#######################################
tabsetPanel(
tabPanel("Plot 1",
sidebarPanel(
numericInput("nobs1", "Observations", min = 50, max = 200, value = 20),
actionButton("submit_button1", "Submit observations")
),
mainPanel(
plotOutput("hist1")
)
), #closes tab panel Plot 1
tabPanel("Plot 2",
sidebarPanel(
numericInput("nobs2", "Observations", min = 50, max = 200, value = 20),
actionButton("submit_button2", "Submit observations")
),
mainPanel(
plotOutput("hist2")
)
) #closes tab panel Plot 2
)#closes tabset panel
)#closes tab panel
) #closes navBarPage
) #closes shinyUI
#####################################
#SERVER
server <- function(input, output){
guide$
init()$
start()
dat1 <- eventReactive(input$submit_button1, {
runif(input$nobs1)
})
dat2 <- eventReactive(input$submit_button2, {
runif(input$nobs2)
})
output$hist1 <- renderPlot({
hist(dat1())
})
output$hist2 <- renderPlot({
hist(dat2())
})
observeEvent(input$guide, {
guide$start()
})
}
shinyApp(ui, server)