I would like to take in a vector of numbers as input and then simply plot the histogram. Here is my R code:
ui.R:
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("Hello Shiny!"),
sidebarPanel(selectInput("Vector", "Select Numbers", c(1,2,3,4), selected = NULL, multiple = TRUE)),
mainPanel( plotOutput("plotVector"))
))
Server.R:
library(shiny)
shinyServer(function(input, output) {
v<- function()
{
v <- rnorm(input$Vector)#take vector as input
}
output$plotVector <- renderPlot({ hist(as.numeric(v))})
})
code to run the app:
library(shiny)
runApp("C:/Users/me/Desktop/R Projects/testShiny")
When I run this I am getting the error "Cannot coerce type 'closure' to vector of type 'double'"
Can you help? Thank you.