通过下载Handler-r Shiny在单个CSV文件中下载多个复选框
我正在尝试创建一个复选框列表,用户可以在其中选择要在单个CSV文件中下载的内容,并且CSV文件应同时显示“ choiceNames”和“ chosecevalues”,该文件在代码中定义了。我在下面写了代码,但是下载按钮不起作用,我不知道如何解决此问题
ui <- fluidPage(
titlePanel(h1(" Worksheet",align="center")),
hr(),
sidebarPanel(
titlePanel(h4("Antenatal Risk Factors/Current Pregnancy",align="center")),
hr(),
checkboxGroupInput("Antel", " ",
choiceNames =
list("Urinary tract infections this pregnancy",
"Urinary tract infections this pregnancy, treated",
"Anemia this pregnancy (HCT < 30/Hgb <10)",
"Hemoglobinopathy this pregnancy",
"Coagulation disorder",
"Rh sensitization",
"Other iso-immunization",
"Biliary/liver disorder(Yes at delivery)",
"Cardiac disease",
"Autoimmune disease",
"Antiphospholipid syndrome",
"Specify collagen vascular disease",
"Asthma",
"Acute or chronic lung disease",
"Renal disorder/disease",
"Renal dialysis or end stage renal disease",
"Thyroid disease",
"Cancer this pregnancy",
"Cancer treatment this pregnancy"
),
choiceValues =list("RFC_INFUT","RFC_INFUTTX",
"RFC_ANEMIA",
"RFC_HEMO",
"COAGULATION_DISORDER",
"RFC_RHS",
"RFC_ISO",
"BILARY_LIVE_DISORD",
"RFC_CDDZ",
"RFC_CVDZ",
"RFC_APSY",
"RFC_CVSPEC",
"RFC_ASTH",
"RFC_LGDZ",
"RENAL_DISORDER_DISEASE",
"RFC_RNDY",
"RFC_THYDZ",
"RFC_CA",
"CANCER_TREATMENT" )
),
checkboxGroupInput("Fetal", "Fetal Conditions",
choiceNames = list("Decreased fetal movement",
"Abnormal fetal heart rate/rhythm",
"Suspected IUGR this pregnancy",
"Fetal compromise this pregnancy",
"Suspected Fetal CNS Anomaly",
"Diagnosed fetal anomaly:",
"Fetal damage",
"Postterm, > 41 6/7 weeks"),
choiceValues = list("RFC_FETMOV",
"RFC_ABRHY","RFC_IUGR",
"RFC_FCOMP",
"RFC_FEANOM",
"RFC_FAN",
"RFC_FD",
"RFC_POST")
),
checkboxGroupInput("Maternal", "Maternal Characteristics",
choiceNames = list("Maternal traumatic injury during this pregnancy",
"Domestic violence during this pregnancy",
"aternal surgical procedure during this pregnancy",
"Other antenatal risk factors during this pregnancy:_____"),
choiceValues = list("RFC_TINJ",
"RFC_VIOL",
"RFC_SURG",
"RFC_OTHR")
),
)
downloadButton("download")
#______________END_______________#
)
server <- function(input, output) {
output$download_checkboxes <- downloadHandler(
filename = function() {
"results.csv"
},
content = function(file) {
Data <- data.frame(selected = input$Antel & input$Fetal )
write.csv(Data, file, row.names = FALSE)
}
)
}
)
shinyApp(ui = ui, server = server)
I'm attempting to create a list of checkboxes where a user can select what they want to download in a single csv file and the csv file should display both 'choiceNames' and 'choiceValues', which defined in the code. I wrote the code below, but the download button does not work, and I don't know how to solve this issue
ui <- fluidPage(
titlePanel(h1(" Worksheet",align="center")),
hr(),
sidebarPanel(
titlePanel(h4("Antenatal Risk Factors/Current Pregnancy",align="center")),
hr(),
checkboxGroupInput("Antel", " ",
choiceNames =
list("Urinary tract infections this pregnancy",
"Urinary tract infections this pregnancy, treated",
"Anemia this pregnancy (HCT < 30/Hgb <10)",
"Hemoglobinopathy this pregnancy",
"Coagulation disorder",
"Rh sensitization",
"Other iso-immunization",
"Biliary/liver disorder(Yes at delivery)",
"Cardiac disease",
"Autoimmune disease",
"Antiphospholipid syndrome",
"Specify collagen vascular disease",
"Asthma",
"Acute or chronic lung disease",
"Renal disorder/disease",
"Renal dialysis or end stage renal disease",
"Thyroid disease",
"Cancer this pregnancy",
"Cancer treatment this pregnancy"
),
choiceValues =list("RFC_INFUT","RFC_INFUTTX",
"RFC_ANEMIA",
"RFC_HEMO",
"COAGULATION_DISORDER",
"RFC_RHS",
"RFC_ISO",
"BILARY_LIVE_DISORD",
"RFC_CDDZ",
"RFC_CVDZ",
"RFC_APSY",
"RFC_CVSPEC",
"RFC_ASTH",
"RFC_LGDZ",
"RENAL_DISORDER_DISEASE",
"RFC_RNDY",
"RFC_THYDZ",
"RFC_CA",
"CANCER_TREATMENT" )
),
checkboxGroupInput("Fetal", "Fetal Conditions",
choiceNames = list("Decreased fetal movement",
"Abnormal fetal heart rate/rhythm",
"Suspected IUGR this pregnancy",
"Fetal compromise this pregnancy",
"Suspected Fetal CNS Anomaly",
"Diagnosed fetal anomaly:",
"Fetal damage",
"Postterm, > 41 6/7 weeks"),
choiceValues = list("RFC_FETMOV",
"RFC_ABRHY","RFC_IUGR",
"RFC_FCOMP",
"RFC_FEANOM",
"RFC_FAN",
"RFC_FD",
"RFC_POST")
),
checkboxGroupInput("Maternal", "Maternal Characteristics",
choiceNames = list("Maternal traumatic injury during this pregnancy",
"Domestic violence during this pregnancy",
"aternal surgical procedure during this pregnancy",
"Other antenatal risk factors during this pregnancy:_____"),
choiceValues = list("RFC_TINJ",
"RFC_VIOL",
"RFC_SURG",
"RFC_OTHR")
),
)
downloadButton("download")
#______________END_______________#
)
server <- function(input, output) {
output$download_checkboxes <- downloadHandler(
filename = function() {
"results.csv"
},
content = function(file) {
Data <- data.frame(selected = input$Antel & input$Fetal )
write.csv(Data, file, row.names = FALSE)
}
)
}
)
shinyApp(ui = ui, server = server)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是您想要的吗?
Is this what you're looking for?