在R中加载图像或文本
我想使用R制作一个简单的web应用程序,通过给出路径并在单击按钮时将其显示在网页上,从硬盘加载图像 我从文本开始,例如显示路径,但是我的按钮在我点击时没有反应(我的意思是说它没有打印消息) 服务器.R:在R中加载图像或文本,r,shiny,shiny-server,R,Shiny,Shiny Server,我想使用R制作一个简单的web应用程序,通过给出路径并在单击按钮时将其显示在网页上,从硬盘加载图像 我从文本开始,例如显示路径,但是我的按钮在我点击时没有反应(我的意思是说它没有打印消息) 服务器.R: shinyServer(function(input, output, session) { dt<-reactive({ output$text1 <- renderText({ paste("You have selected", input$obs) })
shinyServer(function(input, output, session) {
dt<-reactive({
output$text1 <- renderText({
paste("You have selected", input$obs)
})
})
})
使用reactives时,必须将使用输入的代码包装在
reactive
块中,但必须在其外部设置输出值。在这种情况下,您的示例应该是
shinyUI(pageWithSidebar(
headerPanel("Fruits and vegetables!"),
sidebarPanel(
helpText("What do you see below?"),
#imageOutput(outputId="images/1.png")
numericInput("obs", "Number of observations to view:", 10),
actionButton("get", "Get")
),
mainPanel(textOutput("text"))
))
shinyServer(功能(输入、输出、会话){
dt我明白了。但是这段代码只是在动态更新变量,而不是在按下按钮“get”时。如何延迟操作直到按下按钮?我发现它是“提交按钮”这需要存在,而不是操作!操作按钮用于什么?我很抱歉有这么多评论。关于图像URL,我的R脚本中的逻辑将选择图像并在页面上显示它们。我基本上需要从本地计算机向其提供路径名。
shinyUI(pageWithSidebar(
headerPanel("Fruits and vegetables!"),
sidebarPanel(
helpText("What do you see below?"),
#imageOutput(outputId="images/1.png")
numericInput("obs", "Number of observations to view:", 10),
actionButton("get", "Get")
),
mainPanel(textOutput("text"))
))
shinyServer(function(input, output, session) {
dt <- reactive({
paste("You have selected", input$obs)
})
output$text <- renderText({ dt() })
})