我有一个脚本绘制任何类别类型的图表,如A,B和C,我使用“textinput”输入所需的类别 . 现在我想通过URL将此选定的类别传递给另一个脚本 . 此脚本应采用该值并进行计算 . 如何将变量从一个闪亮的脚本传递给另一个作为输入?
那么,通过URL发送数据的方式有很多种 .
这是调度程序应用程序的一个非常原始的示例,使用HTTP GET通过 readlines() 将一些带有Shiny的微小数据发送到远程URL .
readlines()
In this answer,您可以在创建接收器应用程序时阅读如何解析查询字符串中的数据 .
library(shiny) dataToBeSent <- list( "someVariable" = "myValue", "anotherVariable" = "anotherValue" ) ui <- shinyUI( titlePanel("Simply sending some data via HTTP GET") ) server <- shinyServer(function(input, output, session) { sendData <- function ( listData, url ){ print("Server says: Let's pass data to a remote url!") url <- paste0( url,"?",paste(paste( names(listData),unname(listData),sep="=" ),collapse="&")) readLines(URLencode(url)) } sendData( dataToBeSent, "http://www.example.com/shinyApp/" ) }) shinyApp(ui = ui, server = server)
根据您想要实现的目标,如果您想共享大量数据,最好使用共享数据库或使用use an HTTP POST request .
1 回答
那么,通过URL发送数据的方式有很多种 .
这是调度程序应用程序的一个非常原始的示例,使用HTTP GET通过
readlines()
将一些带有Shiny的微小数据发送到远程URL .In this answer,您可以在创建接收器应用程序时阅读如何解析查询字符串中的数据 .
根据您想要实现的目标,如果您想共享大量数据,最好使用共享数据库或使用use an HTTP POST request .