在 Shiny Dashboard 中添加不同类型的选项卡(在 do.call 之后)
Adding different kinds of tabs in Shiny Dashboard (after do.call)
我试图在创建几个视图选项卡(类似结构)后添加一个比较选项卡(不同结构)。此代码引发错误 -
[1] "div"
Error in FUN(X[[i]], ...) : Expected an object with class 'shiny.tag'.
代码-
Some_List <- list("IR", "FX", "EQ")
Some_Long_List <- list("Aggregated Things", "Component 1", "Component 2")
IO_List <- ("Some")
sidebar <- dashboardSidebar(
do.call(sidebarMenu, list(c(lapply(1:length(Some_List), function(i) {
menuItem(Some_Long_List[i], tabName = paste0(Some_List[i],"_tab"))
})),menuItem("Comparison of Files", tabName="Comparison")))
)
uibody <- dashboardBody(
do.call(tabItems, c(lapply(1:length(Some_List), function(i) {
tabItem(tabName = paste0(Some_List[i],"_tab"), h2(Some_Long_List[i]),
fluidPage(fluidRow(column(3,
dateInput(paste0("ME_DATE_output_",Some_List[i]),label=h2("Select a Date"), value="2020-05-29")
,hr()
,actionButton(paste0("calculate_",Some_List[i]), paste0("Calculate ",Some_List[i]),class = "btn-md btn-primary" ))
,column(9,column(verbatimTextOutput(paste0("file_path_",Some_List[i])),width=12),hr(),
selectInput(paste0('select_file_',Some_List[i]),'Select a File to display', choices=NULL),hr(),
column(dataTableOutput(paste0('selected_table_',Some_List[i])),width=12)))))
}))
,tabItem(tabName = "Comparison", h2("Data Comparison"),fluidPage(fluidRow(column(3,
fileInput('Dat1', 'Choose First Data:', accept = c(".csv", ".txt")),
fileInput('Dat2', 'Choose Second Data:', accept = c(".csv", ".txt")))
,column(9,tableOutput('Comparison_Results'))))))
)
)
关于如何在 do.call 之后添加标签的任何帮助?非常感谢。
如果我没理解错的话,你想要:
Some_List <- c("IR", "FX", "EQ")
Some_Long_List <- c("Aggregated Things", "Component 1", "Component 2")
do.call(
tabItems,
c(
lapply(
1:length(Some_List),
function(i) {
tabItem(
tabName = paste0(Some_List[i],"_tab"),
h2(Some_Long_List[i]),
fluidPage(
fluidRow(
column(
3,
dateInput(paste0("ME_DATE_output_",Some_List[i]),label=h2("Select a Date"), value="2020-05-29")
,hr()
,actionButton(paste0("calculate_",Some_List[i]), paste0("Calculate ",Some_List[i]),class = "btn-md btn-primary" )
)
,column(
9,
column(verbatimTextOutput(paste0("file_path_",Some_List[i])),width=12),
hr(),
selectInput(paste0('select_file_',Some_List[i]),'Select a File to display', choices=NULL),
hr(),
column(dataTableOutput(paste0('selected_table_',Some_List[i])),width=12)
)
)
)
)
}
),
list(
tabItem(
tabName = "Comparison",
h2("Data Comparison"),
fluidPage(
fluidRow(
column(
3,
fileInput('Dat1', 'Choose First Data:', accept = c(".csv", ".txt")),
fileInput('Dat2', 'Choose Second Data:', accept = c(".csv", ".txt"))
),
column(
9,
tableOutput('Comparison_Results')
)
)
)
)
)
)
)
我试图在创建几个视图选项卡(类似结构)后添加一个比较选项卡(不同结构)。此代码引发错误 -
[1] "div"
Error in FUN(X[[i]], ...) : Expected an object with class 'shiny.tag'.
代码-
Some_List <- list("IR", "FX", "EQ")
Some_Long_List <- list("Aggregated Things", "Component 1", "Component 2")
IO_List <- ("Some")
sidebar <- dashboardSidebar(
do.call(sidebarMenu, list(c(lapply(1:length(Some_List), function(i) {
menuItem(Some_Long_List[i], tabName = paste0(Some_List[i],"_tab"))
})),menuItem("Comparison of Files", tabName="Comparison")))
)
uibody <- dashboardBody(
do.call(tabItems, c(lapply(1:length(Some_List), function(i) {
tabItem(tabName = paste0(Some_List[i],"_tab"), h2(Some_Long_List[i]),
fluidPage(fluidRow(column(3,
dateInput(paste0("ME_DATE_output_",Some_List[i]),label=h2("Select a Date"), value="2020-05-29")
,hr()
,actionButton(paste0("calculate_",Some_List[i]), paste0("Calculate ",Some_List[i]),class = "btn-md btn-primary" ))
,column(9,column(verbatimTextOutput(paste0("file_path_",Some_List[i])),width=12),hr(),
selectInput(paste0('select_file_',Some_List[i]),'Select a File to display', choices=NULL),hr(),
column(dataTableOutput(paste0('selected_table_',Some_List[i])),width=12)))))
}))
,tabItem(tabName = "Comparison", h2("Data Comparison"),fluidPage(fluidRow(column(3,
fileInput('Dat1', 'Choose First Data:', accept = c(".csv", ".txt")),
fileInput('Dat2', 'Choose Second Data:', accept = c(".csv", ".txt")))
,column(9,tableOutput('Comparison_Results'))))))
)
)
关于如何在 do.call 之后添加标签的任何帮助?非常感谢。
如果我没理解错的话,你想要:
Some_List <- c("IR", "FX", "EQ")
Some_Long_List <- c("Aggregated Things", "Component 1", "Component 2")
do.call(
tabItems,
c(
lapply(
1:length(Some_List),
function(i) {
tabItem(
tabName = paste0(Some_List[i],"_tab"),
h2(Some_Long_List[i]),
fluidPage(
fluidRow(
column(
3,
dateInput(paste0("ME_DATE_output_",Some_List[i]),label=h2("Select a Date"), value="2020-05-29")
,hr()
,actionButton(paste0("calculate_",Some_List[i]), paste0("Calculate ",Some_List[i]),class = "btn-md btn-primary" )
)
,column(
9,
column(verbatimTextOutput(paste0("file_path_",Some_List[i])),width=12),
hr(),
selectInput(paste0('select_file_',Some_List[i]),'Select a File to display', choices=NULL),
hr(),
column(dataTableOutput(paste0('selected_table_',Some_List[i])),width=12)
)
)
)
)
}
),
list(
tabItem(
tabName = "Comparison",
h2("Data Comparison"),
fluidPage(
fluidRow(
column(
3,
fileInput('Dat1', 'Choose First Data:', accept = c(".csv", ".txt")),
fileInput('Dat2', 'Choose Second Data:', accept = c(".csv", ".txt"))
),
column(
9,
tableOutput('Comparison_Results')
)
)
)
)
)
)
)