Error 'data' must be a data frame: Interactive Rmd.

So i am trying to get an interactive R markdown plot that subsets my data based on a selectInput and then generates a ggplot() from there. The error i am getting is

Error: data must be a data frame, or other object coercible by fortify(), not an S3 object with class mts/ts

  "Choose Species", 
  choices = sort(unique(teleost$sp.code)), 
  selected = "ARG", 
  filter(teleost, teleost$sp.code == input$species)

 ggplot2::ggplot(mydata(),, y=rf_no.length) +
  geom_bar(stat='identity') +
  scale_y_continuous(name="Number of Fish",expand=expansion(mult=c(0,0.05))) +
  scale_x_continuous(name="Total Length (mm)") +
  theme_bw() + 
    facet_grid(rows=vars(year), cols=vars(sex), scales="free_y")

I have tried using, but no luck there either.

filter(teleost, sp.code %in% input$species` 

The selectInput works and renders fine but no plot. Any help is appreicated.

(Sorry i cant supply the original data but its for ongoing research)

If i need to create a df for the issue to be solved let me know and i will.


It will be easier to help you, if you add a dataset such that the error is reproducible.

By the way:, do you know that you can debug an Rmarkdown file? You can put a debug statement just before the error happens, to inspect the function inputs.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.