为什么代码在使用多个选项卡时只能部分工作?
Why does the code only work partially when using multiple tabs?
我之前发布了一个关于应用创意的问题 . I decided to add on something similar within the same app so that each tab would have similar function but would deal with different sets of drug instructions. I tried to follow the query and solution posted here,但不知何故丢失了 mainPanel
的大部分输出。
这是包含两个选项卡的代码
library(tidyverse)
library(shiny)
library(shinythemes)
library(xtable)
insulin <- readRDS("insulin.rda")
# User Interface
ui <- fluidPage(
titlePanel("Pre-operative Advice on Long-term Medications for Patients Undergoing Elective Surgery - version 0.1"),
tabsetPanel(
tabPanel("Long-term Medications", fluid = TRUE,
sidebarLayout(
sidebarPanel(
selectInput("specialty", "Choose which surgical subspecialty",
c("Major Orthopaedic Arthroplasty or Revision" = "ortho",
"All other specialties" = "other"),
selected = "All other specialties"),
),
mainPanel(
br(),
uiOutput("drugs_sel"),
h3(textOutput(outputId = "px_name")),
br(),
h4(textOutput(outputId = "dob")),
br(),
tableOutput("drugs_table")
)
)
),
tabPanel("Insulin", fluid = TRUE,
sidebarLayout(
sidebarPanel(
selectInput("DM", "What type of diabetes does patient have?",
c("Type One" = "Type 1",
"Type Two on Insulin" = "Type 2"),
selected = "Type One"),
selectInput("time", "Is patient on morning or afternoon list?",
c("Morning List" = "AM",
"Afternoon List" = "PM"),
selected = "Morning"),
checkboxGroupInput("class", "Which type(s) of insulin is patient on?",
c("Long and Intermediate acting",
"Pre-Mixed",
"Rapid or Short acting"))
),
mainPanel(
br(),
helpText("Choose from the type(s) of insulin from left panel before typing",
"Please ensure the type(s) of insulin are correct before proceeding"),
uiOutput("insulin_sel"),
h3(textOutput(outputId = "px_name")),
br(),
h4(textOutput(outputId = "dob")),
br(),
tableOutput("insulin_table"),
radioButtons('format', 'Document format', c('PDF'),
inline = TRUE),
downloadButton('downloadReport')
)
)
)
)
)
server <- function(input, output){
my_insulin_table <- reactive({
insulin_subset <- insulin %>% filter(DM == input$DM,
Time == input$time,
Class %in% input$class)
tab <- insulin_subset %>% filter(Name %in% input$name) %>% select(Class, Name, Plan)
return(tab)
})
my_drugs_table <- reactive({
drugs_subset <- drugsUI %>% filter(Specialty == input$specialty)
drug_tab <- drugs_subset %>% select(Name, Recommnedations)
return(drug_tab)
})
output$px_name <- renderText({input$px_name})
output$dob <- renderText({input$dob})
output$drugs_sel <- renderUI({
drugs_subset <- drugsUI %>% filter(Specialty == input$specialty)
selectizeInput("drug", "Type in name of drug",
choices = lsit("Type in name of drug" = "",
"Names" = drugs_subset$Name),
selected = NULL,
multiple = TRUE,
options = NULL)
})
output$drug_table <- renderTable({
xtable(my_drugs_table())
})
output$insulin_sel <- renderUI({
insulin_subset <- insulin %>% filter(DM == input$DM,
Time == input$time,
Class %in% input$class)
selectizeInput("name", "Type in name of insulin",
choices = list("Begin typing name of insulin" = "",
"Names" = insulin_subset$Name),
selected = NULL,
multiple = TRUE,
options = NULL)
})
output$insulin_table <- renderTable({
xtable(my_insulin_table())
})
output$downloadReport <- downloadHandler(
filename = function() {("insulin-instructions.pdf")
# paste('my-report', sep = '.', switch(
# input$format, PDF = 'pdf', HTML = 'html', Word = 'docx'
# ))
},
content = function(file) {
src <- normalizePath('report_insulin.Rmd')
# temporarily switch to the temp dir, in case you do not have write
# permission to the current working directory
owd <- setwd(tempdir())
on.exit(setwd(owd))
file.copy(src, 'report_insulin.Rmd', overwrite = TRUE)
library(rmarkdown)
out <- render('report_insulin.Rmd',
params = list(name = input$px_name, dob = input$dob),
'pdf_document')
file.rename(out, file)
}
)
}
shinyApp(ui = ui, server = server)
如果我删除名为 "Long-term Medications"
的 tabPanel
,另一个 tabPanel 似乎又可以工作了。
谁能阐明为什么会这样?我对此很陌生,所以一些解释会对我自己的教育有所帮助。
这些是 dput()
的基础:
dput(tail(drugsUI, 20))
structure(list(Specialty = c("other", "other", "other", "other",
"other", "other", "other", "other", "other", "other", "other",
"other", "other", "other", "other", "other", "ortho", "ortho",
"ortho", "ortho"), Name = c("Ulipristal", "Ursodeoxycholic acid",
"Valproic acid", "Valsartan", "Varenicline", "Venlafaxine", "Verapamil",
"Vigabatrin", "Vildagliptin", "Warfarin", "Zafirlukast", "Zolendronate",
"Zolpidem", "Zopiclone", "Zotepine", "Zuclopenthixol", "Aspirin only",
"Clopidogrel or other -grels only", "NSAIDS for pain (e.g. ibuprofen, naproxen, diclofenac)",
"Dual Antiplatelet (Aspirin AND Clopidogrel)"), Recommendations = c("Continue –may not be needed post op if removing uterine fibroids",
"Continue", "Continue", "Omit on day of surgery if used for high blood pressure, continue for congestive heart failure",
"Continue", "Continue – but avoid pethidine use", "Continue",
"Continue", "See Diabetes Guideline. Usually omitted morning of surgery",
"See Anticoagulation/Antiplatelet Guideline", "Continue", "Continue - but may be safely omitted if due day of procedure",
"Continue", "Continue", "Continue", "Continue", "Stop 7 days before surgery",
"See below graphic", "Stop 2 days before surgery", "Review medical indication - Surgery should be deferred until patient on single antiplatelet (i.e. Aspirin OR Clopidogrel; if not possible discuss with sugeon, anaesthetist and cardiologist about plan. Ideally continue at least aspirin"
)), row.names = c(NA, -20L), class = c("tbl_df", "tbl", "data.frame"
))
structure(list(DM = c("Type 2", "Type 2", "Type 2", "Type 2",
"Type 2", "Type 2", "Type 2", "Type 2", "Type 2", "Type 2", "Type 2",
"Type 2", "Type 2", "Type 2", "Type 1", "Type 1", "Type 1", "Type 1",
"Type 1", "Type 1", "Type 1", "Type 1", "Type 1", "Type 1", "Type 1",
"Type 1", "Type 1", "Type 1", "Type 2", "Type 2", "Type 2", "Type 2",
"Type 2", "Type 2", "Type 2", "Type 2", "Type 1", "Type 1", "Type 1",
"Type 1", "Type 1", "Type 1", "Type 1", "Type 1", "Type 2", "Type 2",
"Type 2", "Type 2", "Type 2", "Type 2", "Type 2", "Type 2", "Type 2",
"Type 2", "Type 1", "Type 1", "Type 1", "Type 1", "Type 1", "Type 1",
"Type 1", "Type 1", "Type 1", "Type 1"), Time = c("AM", "AM",
"AM", "AM", "AM", "AM", "AM", "PM", "PM", "PM", "PM", "PM", "PM",
"PM", "AM", "AM", "AM", "AM", "AM", "AM", "AM", "PM", "PM", "PM",
"PM", "PM", "PM", "PM", "AM", "AM", "AM", "AM", "PM", "PM", "PM",
"PM", "AM", "AM", "AM", "AM", "PM", "PM", "PM", "PM", "AM", "AM",
"AM", "AM", "AM", "PM", "PM", "PM", "PM", "PM", "AM", "AM", "AM",
"AM", "AM", "PM", "PM", "PM", "PM", "PM"), Class = c("Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Pre-Mixed", "Pre-Mixed", "Pre-Mixed",
"Pre-Mixed", "Pre-Mixed", "Pre-Mixed", "Pre-Mixed", "Pre-Mixed",
"Pre-Mixed", "Pre-Mixed", "Pre-Mixed", "Pre-Mixed", "Pre-Mixed",
"Pre-Mixed", "Pre-Mixed", "Pre-Mixed", "Rapid or Short acting",
"Rapid or Short acting", "Rapid or Short acting", "Rapid or Short acting",
"Rapid or Short acting", "Rapid or Short acting", "Rapid or Short acting",
"Rapid or Short acting", "Rapid or Short acting", "Rapid or Short acting",
"Rapid or Short acting", "Rapid or Short acting", "Rapid or Short acting",
"Rapid or Short acting", "Rapid or Short acting", "Rapid or Short acting",
"Rapid or Short acting", "Rapid or Short acting", "Rapid or Short acting",
"Rapid or Short acting"), Name = c("Abasaglar", "Lantus", "Levemir",
"Toujeo", "Tresiba", "Insulatard", "Humulin I", "Abasaglar",
"Lantus", "Levemir", "Toujeo", "Tresiba", "Insulatard", "Humulin I",
"Abasaglar", "Lantus", "Levemir", "Toujeo", "Tresiba", "Insulatard",
"Humulin I", "Abasaglar", "Lantus", "Levemir", "Toujeo", "Tresiba",
"Insulatard", "Humulin I", "Humulin M3", "Novomix 30", "Insuman Comb 15/25/50",
"Humalog Mix 25/50", "Humulin M3", "Novomix 30", "Insuman Comb 15/25/50",
"Humalog Mix 25/50", "Humulin M3", "Novomix 30", "Insuman Comb 15/25/50",
"Humalog Mix 25/50", "Humulin M3", "Novomix 30", "Insuman Comb 15/25/50",
"Humalog Mix 25/50", "Novorapid/Fiasp", "Humalog", "Apidra",
"Humulin S", "Actrapid", "Novorapid/Fiasp", "Humalog", "Apidra",
"Humulin S", "Actrapid", "Novorapid/Fiasp", "Humalog", "Apidra",
"Humulin S", "Actrapid", "Novorapid/Fiasp", "Humalog", "Apidra",
"Humulin S", "Actrapid"), Plan = c("Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Half usual morning dose taken with a sugary drink at 7am", "Half usual morning dose taken with a sugary drink at 7am",
"Half usual morning dose taken with a sugary drink at 7am", "Half usual morning dose taken with a sugary drink at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a sugary drink at 7am", "Half usual morning dose taken with a sugary drink at 7am",
"Half usual morning dose taken with a sugary drink at 7am", "Half usual morning dose taken with a sugary drink at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Omit breakfast dose", "Omit breakfast dose", "Omit breakfast dose",
"Omit breakfast dose", "Omit breakfast dose", "Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Omit breakfast dose", "Omit breakfast dose", "Omit breakfast dose",
"Omit breakfast dose", "Omit breakfast dose", "Usual morning dose taken with a light breakfast at 7am, oral fluids until 11am, omit lunchtime dose",
"Usual morning dose taken with a light breakfast at 7am, oral fluids until 11am, omit lunchtime dose",
"Usual morning dose taken with a light breakfast at 7am, oral fluids until 11am, omit lunchtime dose",
"Usual morning dose taken with a light breakfast at 7am, oral fluids until 11am, omit lunchtime dose",
"Usual morning dose taken with a light breakfast at 7am, oral fluids until 11am, omit lunchtime dose"
)), row.names = c(NA, -64L), class = c("tbl_df", "tbl", "data.frame"
))
Shiny 不支持同名的多个输出。看看 .
在您的情况下,两个选项卡都使用 px_name
和 dob
。在您的服务器代码中,您可以尝试类似的操作:
output$dob1 <- output$dob2 <- renderText({input$dob})
然后在 UI 选项卡中引用这些单独的输出 ID。
希望这有帮助。
我之前发布了一个关于应用创意的问题 mainPanel
的大部分输出。
这是包含两个选项卡的代码
library(tidyverse)
library(shiny)
library(shinythemes)
library(xtable)
insulin <- readRDS("insulin.rda")
# User Interface
ui <- fluidPage(
titlePanel("Pre-operative Advice on Long-term Medications for Patients Undergoing Elective Surgery - version 0.1"),
tabsetPanel(
tabPanel("Long-term Medications", fluid = TRUE,
sidebarLayout(
sidebarPanel(
selectInput("specialty", "Choose which surgical subspecialty",
c("Major Orthopaedic Arthroplasty or Revision" = "ortho",
"All other specialties" = "other"),
selected = "All other specialties"),
),
mainPanel(
br(),
uiOutput("drugs_sel"),
h3(textOutput(outputId = "px_name")),
br(),
h4(textOutput(outputId = "dob")),
br(),
tableOutput("drugs_table")
)
)
),
tabPanel("Insulin", fluid = TRUE,
sidebarLayout(
sidebarPanel(
selectInput("DM", "What type of diabetes does patient have?",
c("Type One" = "Type 1",
"Type Two on Insulin" = "Type 2"),
selected = "Type One"),
selectInput("time", "Is patient on morning or afternoon list?",
c("Morning List" = "AM",
"Afternoon List" = "PM"),
selected = "Morning"),
checkboxGroupInput("class", "Which type(s) of insulin is patient on?",
c("Long and Intermediate acting",
"Pre-Mixed",
"Rapid or Short acting"))
),
mainPanel(
br(),
helpText("Choose from the type(s) of insulin from left panel before typing",
"Please ensure the type(s) of insulin are correct before proceeding"),
uiOutput("insulin_sel"),
h3(textOutput(outputId = "px_name")),
br(),
h4(textOutput(outputId = "dob")),
br(),
tableOutput("insulin_table"),
radioButtons('format', 'Document format', c('PDF'),
inline = TRUE),
downloadButton('downloadReport')
)
)
)
)
)
server <- function(input, output){
my_insulin_table <- reactive({
insulin_subset <- insulin %>% filter(DM == input$DM,
Time == input$time,
Class %in% input$class)
tab <- insulin_subset %>% filter(Name %in% input$name) %>% select(Class, Name, Plan)
return(tab)
})
my_drugs_table <- reactive({
drugs_subset <- drugsUI %>% filter(Specialty == input$specialty)
drug_tab <- drugs_subset %>% select(Name, Recommnedations)
return(drug_tab)
})
output$px_name <- renderText({input$px_name})
output$dob <- renderText({input$dob})
output$drugs_sel <- renderUI({
drugs_subset <- drugsUI %>% filter(Specialty == input$specialty)
selectizeInput("drug", "Type in name of drug",
choices = lsit("Type in name of drug" = "",
"Names" = drugs_subset$Name),
selected = NULL,
multiple = TRUE,
options = NULL)
})
output$drug_table <- renderTable({
xtable(my_drugs_table())
})
output$insulin_sel <- renderUI({
insulin_subset <- insulin %>% filter(DM == input$DM,
Time == input$time,
Class %in% input$class)
selectizeInput("name", "Type in name of insulin",
choices = list("Begin typing name of insulin" = "",
"Names" = insulin_subset$Name),
selected = NULL,
multiple = TRUE,
options = NULL)
})
output$insulin_table <- renderTable({
xtable(my_insulin_table())
})
output$downloadReport <- downloadHandler(
filename = function() {("insulin-instructions.pdf")
# paste('my-report', sep = '.', switch(
# input$format, PDF = 'pdf', HTML = 'html', Word = 'docx'
# ))
},
content = function(file) {
src <- normalizePath('report_insulin.Rmd')
# temporarily switch to the temp dir, in case you do not have write
# permission to the current working directory
owd <- setwd(tempdir())
on.exit(setwd(owd))
file.copy(src, 'report_insulin.Rmd', overwrite = TRUE)
library(rmarkdown)
out <- render('report_insulin.Rmd',
params = list(name = input$px_name, dob = input$dob),
'pdf_document')
file.rename(out, file)
}
)
}
shinyApp(ui = ui, server = server)
如果我删除名为 "Long-term Medications"
的 tabPanel
,另一个 tabPanel 似乎又可以工作了。
谁能阐明为什么会这样?我对此很陌生,所以一些解释会对我自己的教育有所帮助。
这些是 dput()
的基础:
dput(tail(drugsUI, 20))
structure(list(Specialty = c("other", "other", "other", "other",
"other", "other", "other", "other", "other", "other", "other",
"other", "other", "other", "other", "other", "ortho", "ortho",
"ortho", "ortho"), Name = c("Ulipristal", "Ursodeoxycholic acid",
"Valproic acid", "Valsartan", "Varenicline", "Venlafaxine", "Verapamil",
"Vigabatrin", "Vildagliptin", "Warfarin", "Zafirlukast", "Zolendronate",
"Zolpidem", "Zopiclone", "Zotepine", "Zuclopenthixol", "Aspirin only",
"Clopidogrel or other -grels only", "NSAIDS for pain (e.g. ibuprofen, naproxen, diclofenac)",
"Dual Antiplatelet (Aspirin AND Clopidogrel)"), Recommendations = c("Continue –may not be needed post op if removing uterine fibroids",
"Continue", "Continue", "Omit on day of surgery if used for high blood pressure, continue for congestive heart failure",
"Continue", "Continue – but avoid pethidine use", "Continue",
"Continue", "See Diabetes Guideline. Usually omitted morning of surgery",
"See Anticoagulation/Antiplatelet Guideline", "Continue", "Continue - but may be safely omitted if due day of procedure",
"Continue", "Continue", "Continue", "Continue", "Stop 7 days before surgery",
"See below graphic", "Stop 2 days before surgery", "Review medical indication - Surgery should be deferred until patient on single antiplatelet (i.e. Aspirin OR Clopidogrel; if not possible discuss with sugeon, anaesthetist and cardiologist about plan. Ideally continue at least aspirin"
)), row.names = c(NA, -20L), class = c("tbl_df", "tbl", "data.frame"
))
structure(list(DM = c("Type 2", "Type 2", "Type 2", "Type 2",
"Type 2", "Type 2", "Type 2", "Type 2", "Type 2", "Type 2", "Type 2",
"Type 2", "Type 2", "Type 2", "Type 1", "Type 1", "Type 1", "Type 1",
"Type 1", "Type 1", "Type 1", "Type 1", "Type 1", "Type 1", "Type 1",
"Type 1", "Type 1", "Type 1", "Type 2", "Type 2", "Type 2", "Type 2",
"Type 2", "Type 2", "Type 2", "Type 2", "Type 1", "Type 1", "Type 1",
"Type 1", "Type 1", "Type 1", "Type 1", "Type 1", "Type 2", "Type 2",
"Type 2", "Type 2", "Type 2", "Type 2", "Type 2", "Type 2", "Type 2",
"Type 2", "Type 1", "Type 1", "Type 1", "Type 1", "Type 1", "Type 1",
"Type 1", "Type 1", "Type 1", "Type 1"), Time = c("AM", "AM",
"AM", "AM", "AM", "AM", "AM", "PM", "PM", "PM", "PM", "PM", "PM",
"PM", "AM", "AM", "AM", "AM", "AM", "AM", "AM", "PM", "PM", "PM",
"PM", "PM", "PM", "PM", "AM", "AM", "AM", "AM", "PM", "PM", "PM",
"PM", "AM", "AM", "AM", "AM", "PM", "PM", "PM", "PM", "AM", "AM",
"AM", "AM", "AM", "PM", "PM", "PM", "PM", "PM", "AM", "AM", "AM",
"AM", "AM", "PM", "PM", "PM", "PM", "PM"), Class = c("Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Long and Intermediate acting",
"Long and Intermediate acting", "Pre-Mixed", "Pre-Mixed", "Pre-Mixed",
"Pre-Mixed", "Pre-Mixed", "Pre-Mixed", "Pre-Mixed", "Pre-Mixed",
"Pre-Mixed", "Pre-Mixed", "Pre-Mixed", "Pre-Mixed", "Pre-Mixed",
"Pre-Mixed", "Pre-Mixed", "Pre-Mixed", "Rapid or Short acting",
"Rapid or Short acting", "Rapid or Short acting", "Rapid or Short acting",
"Rapid or Short acting", "Rapid or Short acting", "Rapid or Short acting",
"Rapid or Short acting", "Rapid or Short acting", "Rapid or Short acting",
"Rapid or Short acting", "Rapid or Short acting", "Rapid or Short acting",
"Rapid or Short acting", "Rapid or Short acting", "Rapid or Short acting",
"Rapid or Short acting", "Rapid or Short acting", "Rapid or Short acting",
"Rapid or Short acting"), Name = c("Abasaglar", "Lantus", "Levemir",
"Toujeo", "Tresiba", "Insulatard", "Humulin I", "Abasaglar",
"Lantus", "Levemir", "Toujeo", "Tresiba", "Insulatard", "Humulin I",
"Abasaglar", "Lantus", "Levemir", "Toujeo", "Tresiba", "Insulatard",
"Humulin I", "Abasaglar", "Lantus", "Levemir", "Toujeo", "Tresiba",
"Insulatard", "Humulin I", "Humulin M3", "Novomix 30", "Insuman Comb 15/25/50",
"Humalog Mix 25/50", "Humulin M3", "Novomix 30", "Insuman Comb 15/25/50",
"Humalog Mix 25/50", "Humulin M3", "Novomix 30", "Insuman Comb 15/25/50",
"Humalog Mix 25/50", "Humulin M3", "Novomix 30", "Insuman Comb 15/25/50",
"Humalog Mix 25/50", "Novorapid/Fiasp", "Humalog", "Apidra",
"Humulin S", "Actrapid", "Novorapid/Fiasp", "Humalog", "Apidra",
"Humulin S", "Actrapid", "Novorapid/Fiasp", "Humalog", "Apidra",
"Humulin S", "Actrapid", "Novorapid/Fiasp", "Humalog", "Apidra",
"Humulin S", "Actrapid"), Plan = c("Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Usual dose at usual time", "Usual dose at usual time", "Usual dose at usual time",
"Half usual morning dose taken with a sugary drink at 7am", "Half usual morning dose taken with a sugary drink at 7am",
"Half usual morning dose taken with a sugary drink at 7am", "Half usual morning dose taken with a sugary drink at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a sugary drink at 7am", "Half usual morning dose taken with a sugary drink at 7am",
"Half usual morning dose taken with a sugary drink at 7am", "Half usual morning dose taken with a sugary drink at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Omit breakfast dose", "Omit breakfast dose", "Omit breakfast dose",
"Omit breakfast dose", "Omit breakfast dose", "Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Half usual morning dose taken with a light breakfast at 7am",
"Omit breakfast dose", "Omit breakfast dose", "Omit breakfast dose",
"Omit breakfast dose", "Omit breakfast dose", "Usual morning dose taken with a light breakfast at 7am, oral fluids until 11am, omit lunchtime dose",
"Usual morning dose taken with a light breakfast at 7am, oral fluids until 11am, omit lunchtime dose",
"Usual morning dose taken with a light breakfast at 7am, oral fluids until 11am, omit lunchtime dose",
"Usual morning dose taken with a light breakfast at 7am, oral fluids until 11am, omit lunchtime dose",
"Usual morning dose taken with a light breakfast at 7am, oral fluids until 11am, omit lunchtime dose"
)), row.names = c(NA, -64L), class = c("tbl_df", "tbl", "data.frame"
))
Shiny 不支持同名的多个输出。看看
在您的情况下,两个选项卡都使用 px_name
和 dob
。在您的服务器代码中,您可以尝试类似的操作:
output$dob1 <- output$dob2 <- renderText({input$dob})
然后在 UI 选项卡中引用这些单独的输出 ID。 希望这有帮助。