在我正在创建的闪亮应用程序中,我有一组彼此互连的下拉列表框。即一个下拉框的输入决定了其他下拉框的一组输入。
对于下拉框,我使用 selectInput() 函数来执行此操作,并且还有一些下拉框,我需要从中选择多个选项。
但当选项数量较多时,用户需要单独选择每个选项。有什么办法可以一次选择所有选项。
这有点像“全部”选项。它选择一切。
我不想使用"pickerInput"
函数。
由于下拉列表中的选项取决于之前的下拉输入,因此我无法创建静态选择列表。
作为解决方法,我使用复选框输入来选择下拉列表中的所有值,但不幸的是它不起作用。
请在下面找到 UI 和服务器代码。
Source_Data <-
data.frame(
key = c(1, 1, 1, 2, 2, 2, 3, 3, 3),
Product_Name = c(
"Table",
"Table",
"Chair",
"Table",
"Bed",
"Bed",
"Sofa",
"Chair",
"Sofa"
),
Product_desc = c("XX", "XX", "YY", "XX", "Z", "ZZZ", "A", "Y", "AA"),
Cost = c(1, 2, 3, 4, 2, 3, 4, 5, 6)
)
Run Code Online (Sandbox Code Playgroud)
UI 和服务器代码
ui <- fluidPage(titlePanel("Demo"),
sidebarLayout(
sidebarPanel(
sliderInput(
"key",
"keys",
min = 1,
max = 3, …
Run Code Online (Sandbox Code Playgroud) 我使用 ggplotly 绘制图形。当光标移动到图形顶部时,我使用工具提示函数来表示条形图中的值。
Source_Data <-
data.frame(
key = c(1, 1, 1, 2, 2, 2, 3, 3, 3),
Product_Name = c(
"Table",
"Table",
"Chair",
"Table",
"Bed",
"Bed",
"Sofa",
"Chair",
"Sofa"
),
Product_desc = c("XX", "XXXX", "YY", "X", "Z", "ZZZ", "A", "Y", "A"),
sd = c(0.1, 0.3, 0.4, 0.5, 0.6, 0.7, 0.7, 0.8, 0.5),
Cost = c(1, 2, 3, 4, 2, 3, 4, 5, 6)
)
ggplotly((
Source_Data %>%
ggplot(
aes(
Product_Name,
Cost,
ymin = Cost - sd,
ymax = Cost + …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个闪亮的应用程序。在这个特定的应用程序中,我有一组单选按钮,其中选择一个将在下面显示一组选项作为复选框,选择另一个单选按钮将选择其他选项集。请在下面找到 UI 和服务器代码。
library(shiny)
library(shinydashboard)
library(shinyWidgets)
d <-
data.frame(
year = c(1995, 1995, 1995, 1996, 1996, 1996, 1997, 1997, 1997),
Product_Name = c(
"Table",
"Chair",
"Bed",
"Table",
"Chair",
"Bed",
"Table",
"Chair",
"Bed"
),
Product_desc = c("X", "X", "X", "Y", "Y", "Y", "Z", "Z", "Z"),
Cost = c(1, 2, 3, 4, 2, 3, 4, 5, 6)
)
ui <- shinyUI(fluidPage(
useShinydashboard(),
tabPanel(
"Plot",
sidebarLayout(
sidebarPanel(
radioButtons(
"Choose",
"Choose One",
c("Year" = "p", "Numbers" = "l")
),
uiOutput('checkbox'),
#width = 2,
position …
Run Code Online (Sandbox Code Playgroud)