1
votes

I am new to shiny . when I run these codes :

UI:

library(shiny)

shinyUI(pageWithSidebar(
  headerPanel("Hi"),
   sidebarPanel(selectInput('variable','parameter:',list('mipigi'='mpg',"cylender"='cyl',"displacement"='disp',"horsepower"='hp'))
  ),

  mainPanel(
   h3(textOutput("caption")),
   plotOutput("histo")

   )
  ))

Server:

library(shiny)
library(datasets)

shinyServer(function(input,output){
formulaText <- reactive({
paste("qsec~", input$variable)
 })
output$caption <- renderText({
formulaText()
 })
output$histo<-renderPlot({
 plot(as.formula(formulaText),mtcars)

  })
 }
) 

When I run it , I got the error :

Error:object of type 'closure' is not subsettable

1

1 Answers

0
votes

In your plot call make it.

plot(as.formula(formulaText()),mtcars)