Error in FUN cannot coerce type closure to vector of type character No stack trace available in R

+2 votes

Error in FUN: cannot coerce type 'closure' to vector of type 'character'
  [No stack trace available]

What to do?

I'm new to R. Below is my code - 

library(shiny)
ui <- fluidPage(
  tabsetPanel(
    tabPanel("Plot", plotOutput(plot)),
    tabPanel("ggplot", plotOutput(ggplot))
  )
)

server <- function(input,output) {
  output$plot = renderPlot({ plot(mpg$hwy,mpg$cty,col = colors(length(mpg$hwy))) })
  output$ggplot = renderPlot({ ggplot(mpg, aes(hwy, cty,fill = year)) + geom_point() + theme_bw() })
}

shinyApp(ui = ui,server = server)
Jul 17, 2019 in Data Analytics by ramya
16,740 views

1 answer to this question.

0 votes

You missed out " " for variables in the plotOutput function.

Write as below - 

library(shiny)
ui <- fluidPage(
  tabsetPanel(
    tabPanel("Plot", plotOutput("plot")),
    tabPanel("ggplot", plotOutput("ggplot"))
  )
)

server <- function(input,output) {
  output$plot = renderPlot({ plot(mpg$hwy,mpg$cty,col = colors(length(mpg$hwy))) })
  output$ggplot = renderPlot({ ggplot(mpg, aes(hwy, cty,fill = year)) + geom_point() + theme_bw() })
}

shinyApp(ui = ui,server = server)
answered Jul 17, 2019 by Cherukuri
• 33,030 points

Related Questions In Data Analytics

0 votes
1 answer

Error saying "Error in df$item : object of type 'closure' is not subsettable" when trying to use arules package

Try replacing ID <- c("A123","A123","A123","A123","B456","B456","B456") item <- c("bread", "butter", ...READ MORE

answered Nov 15, 2018 in Data Analytics by Maverick
• 10,840 points
1,767 views
0 votes
1 answer

How to write a custom function which will replace all the missing values in a vector with the mean of values in R?

Consider this vector: a<-c(1,2,3,NA,4,5,NA,NA) Write the function to impute ...READ MORE

answered Jul 4, 2018 in Data Analytics by CodingByHeart77
• 3,750 points
4,556 views
+1 vote
1 answer

Error saying "could not find function "shinyUI"" in shiny R

Its a small spelling mistake that you've ...READ MORE

answered Nov 28, 2018 in Data Analytics by Maverick
• 10,840 points
2,626 views
+1 vote
1 answer

Error saying "could not find function dashboardPage" in shiny R

Include this line in the code: Library(shinydashboard) READ MORE

answered Nov 29, 2018 in Data Analytics by Maverick
• 10,840 points
3,659 views
0 votes
1 answer

How to replace all occurrences of a character in a character column in a data frame in R

If you used sub() to replace the ...READ MORE

answered Jun 29, 2019 in Data Analytics by anonymous
• 33,030 points
17,936 views
0 votes
1 answer

R Shiny Error: Object of type 'closure' is not subsettable

The error you mentioned happens when you ...READ MORE

answered Aug 20, 2019 in Data Analytics by anonymous
• 33,030 points
6,361 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP