我有一个功能齐全的闪亮的,由四个不同的模块构成,在第一个模块中,我们上传我们拥有的数据集,在第二个和第三个模块中,我们可以基于第一个模块进行绘图,在第四个模块中,我们应该能够生成连接到 rmd 的报告。文件。但是我想从中渲染 HTML 或 PDF 报告,如何才能完成?在普通的闪亮中,我们将绘图的反应函数放入“report.Rmd”文件中,它将呈现报告。然而,对于模块来说并不是那么容易,为了基于多个模块生成报告,有什么解决方案吗?提前致谢!
file_upload_UI <- function(id) {
ns <- NS(id)
tabPanel(
"Upload File",
titlePanel("Uploading Files"),
sidebarLayout(
sidebarPanel(
fileInput(ns("file1"), "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv"
)
),
tags$br(),
checkboxInput(ns("header"), "Header", TRUE),
radioButtons(
ns("sep"),
"Separator",
c(
Comma = ",",
Semicolon = ";",
Tab = "\t"
),
","
),
radioButtons(
ns("quote"),
"Quote",
c(
None = "",
"Double Quote" = '"',
"Single Quote" = "'"
),
'"'
)
),
mainPanel(
tableOutput(ns("contents"))
)
)
)
}
file_upload_Server <- …Run Code Online (Sandbox Code Playgroud) 我在 R Shiny 应用程序中将变量从模块返回到服务器时遇到了令人惊讶的困难。在模块中,我想在观察到按下按钮时返回一个值,因此我将return()语句包装在observeEvent(). 但是,没有返回所需的值,整个observeEvent()块似乎是。
我试图创建一个最小的工作示例,概述以下问题:
# ui.R
fluidPage(
input_module_ui("input"),
actionButton("print_input_button",
label = "Print Input")
)
Run Code Online (Sandbox Code Playgroud)
# server.R
function(input, output, session) {
# Calling input module.
input_module_return <- callModule(input_module, "input")
observeEvent(input$print_input_button, {
print(input_module_return)
})
}
Run Code Online (Sandbox Code Playgroud)
# global.R
source("modules/input.R")
Run Code Online (Sandbox Code Playgroud)
# input.R
input_module_ui <- function(id) {
ns <- NS(id)
tagList(
textInput(ns("text_input"),
label = h2("Input Text:")),
actionButton(ns("submit_input"),
label = "Submit Input")
)
}
input_module <- function(input, output, session) {
print("I should only print …Run Code Online (Sandbox Code Playgroud)