2017-06-12 171 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)) 
}