我没有一个可重复的例子,因为问题更多的是模块如何工作.我试图了解如何将一些反应函数从一个模块传递到下一个模块.我在过去收到过有关使用ObserveEvent的回复,但是当我在一个模块中使用反应值来在另一个模块中执行某些其他操作时它们似乎无法工作
module1 <- function(input, output, session){
data1<-reactive({
#some reacttive funcion that produces an output
})
data2<-reactive({
#some reacttive funcion that produces another output
})
return(list(data1,data2))
}
module2 <- function(input, output, session,data1){
observe( data1(), {
#perform some other functions here using data1().e.g reading or parsing data
})
}
Run Code Online (Sandbox Code Playgroud)
所以基本上我有一个module1,它返回data1和data2的两个输出
我想在模块2中使用data1的值,并使用该值执行一些新操作.
我在这里看了类似问题的其他答案,但我仍然不理解它们.如果有人可以帮助我更清楚地解释这个概念,那将非常有用,感谢您的帮助
我想知道如何将一个模块中的反应式函数访问到另一个模块。如果我在一个模块中有多个反应性函数,我可以在另一个模块中访问它们吗?
所以基本上我将如何调用/传递一个闪亮模块中的反应函数到另一个闪亮模块(从一个模块到另一个模块的反应函数)谢谢
module1Ui <- function(id) {
ns <- NS(id)
wellPanel(selectInput(
ns("cars"),
"cars:",
list(
"Select" = "",
"a" = "mazda",
"b" = "ford"
)
))
}
module1 <- function(input, output, session) {
dataone <- reactive({
if (input$cars == "mazda") {
mtcars$mpg
}
else {
(mtcars$hp)
}
})
}
module2 <- function(input, output, session) {
dataone()
# here I want dataone from the above module1
# I tried to use callmodule(module1,_) but then didnt understand what the id would be in this …
Run Code Online (Sandbox Code Playgroud)