I build shinydashboard that has 6 tabItem. I want to use cicerone package to guide first tibeItem. I write following code:
library(shiny)
library(shinydashvoard)
guide <- Cicerone$
new(id = "homeGuide")$
step(
el = "macro_upload",
title = "Upload Macro Data",
description = "This is where you upload macro data."
)$
step(
el = "mcr_df",
title = "Sample of Data",
description = "Here you can see sample of your data"
)$
step(
"adf_test",
"ADF Test result",
"Hare you can see result of ADF test, for choosen variable"
)$
step(
el = "slider-wrapper",
title = "choose lag",
description= "Choose lag in ADF test"
)
ui <- dashboardPage(
dashboardHeader(title = "PD Model"),
dashboardSidebar(
sidebarMenu(
menuItem("Stationary test", tabName = "stationary", icon = icon("chart-line")),
menuItem("Import Data", tabName = "import", icon = icon("server")),
menuItem("Explore Data", tabName = "explore", icon = icon("cogs")),
menuItem("Visualise Data", tabName = "visualisation", icon = icon("bar-chart")),
menuItem("Model development", tabName = "development", icon = icon("layer-group")),
menuItem("Validation", tabName = "validation", icon = icon("tools"))
)
),
dashboardBody(
use_cicerone(),
tags$head(
tags$style(HTML('
.main-header .logo {
font-family: "Georgia", Times, "Times New Roman", serif;
font-weight: bold;
font-size: 24px;
}
'))),
tabItems(
####### Zero Tab ####
tabItem(tabName = "stationary",
box(width = 5, height = 400,
title = "Upload Data", status = "primary", solidHeader = F,
collapsible = T, background = "light-blue",
fileInput(inputId = "macro_upload",
label = "Upload Macro Data",
multiple = TRUE,
buttonLabel = "Upload...",
accept = c('csv','tsv')),
actionButton(inputId = "tutorial", label = "Tutorial"),
dataTableOutput("mcr_df", width = '100%')
),
box(width = 6,
height = 400,
title = "Augmented dicky-fuller test", status = "primary", solidHeader = F,
collapsible = T, background = "teal",
fluidRow(
column(
width = 4,
div(
id = "slider-wrapper",
sliderInput("adf_lag", "choose lag", value = 3, min = 0, max = 12)
)
),
column(
width = 4,
selectInput("type_adf", "choose type", choices = c("none", "drift", "trend"))
),
column(
width = 4,
selectInput("macro_var", "Macro variable", choices = c())
)
),
fluidRow(
column(
width = 12,
dataTableOutput('adf_test')
)
)
)
)
### other tabs are here ####
### server ####
server <- function(input, output, session) {
guide$init()$start()
macro_df <- reactive({
req(input$macro_upload)
ext_0 <- tools::file_ext(input$macro_upload$name)
switch(ext_0,
csv = vroom::vroom(input$macro_upload$datapath, delim = ","),
tsv = vroom::vroom(input$macro_upload$datapath, delim = "\t"),
validate("Invalid file; Please upload a .csv or .tsv file")
)
})
output$mcr_df <- renderDataTable(macro_df(),
extensions = 'FixedColumns',
options = list(
pageLength = 5,
dom = 't',
scrollX = TRUE,
fixedColumns = TRUE))
observeEvent(macro_df(), {
updateSelectInput(session, "macro_var", choices = names(macro_df()))
})
adf_result <- reactive({
req(input$macro_var)
var_adf_0 = macro_df() %>% select(.data[[input$macro_var]])
var_adf = reactive(ur.df(y = as.matrix(var_adf_0), type = input$type_adf, lags = input$adf_lag))
cbind(t(var_adf()@teststat), var_adf()@cval)
})
output$adf_test <- renderDataTable({
datatable(round(adf_result(),4), options = list(
initComplete = JS(
"function(settings, json) {",
"$(this.api().table().header()).css({'background-color': '#000', 'color': '#fff'});",
"}")
))
})
### other tabitems server function are here ####
shinyApp(ui, server)
but cicerone does not work.
what is problem and how to handle it?
Thnaks