Error: object of type 'closure' is not subsettable

Hi @mikeozga! Welcome!

Your code hasn't actually created an object named data, so R is falling back to the function data() (used for loading built-in datasets). A function is called a "closure" by R.

Were you maybe adapting this code from an example somewhere? I'm not quite sure what you're doing here and I can't run your code (it's not reproducible as-is, since it relies on files local to your system), but I suspect you need to have the name of your data frame pitcher in the place of data.

To learn more about how to make your code questions as easy as possible to answer, take a look at this FAQ:

1 Like