2017-06-12 170 views
0

我想在Shiny R中写一个简单的应用程序。 我想要两个输入(x和y)并绘制相对散点图。代码如下闪亮的R,Plot,ShinyApp

library(shiny) 

ui<-fluidPage(
headerPanel('Plot'), 

sidebarPanel(
sliderInput(inputId = 'x',label='X', value = 1,min=1,max=3), 


sliderInput(inputId = 'y',label='Y', value = 1,min=1,max=3) 
), 

mainPanel(
plotOutput('plot') 
) 
) 

server<-function(input,output) { 
x <- reactive({input$x}) 

y <- reactive({input$y}) 

output$plot <- renderPlot({plot(x,y)}) 
} 


shinyApp(ui=ui, server=server) 

的代码产生一个错误,

cannot coerce type 'closure' to vector of type 'double' 

我如何纠正呢?

非常感谢您

回答

2

X和Y功能,从而增加()他们

output$plot <- renderPlot({plot(x(),y())})

0

您可以使用此服务器的说法相反:

server <- function(input,output) { 
    output$plot <- renderPlot(plot(input$x,input$y)) 
}