Skip to content

Instantly share code, notes, and snippets.

View ryan-heslin's full-sized avatar

Ryan Heslin ryan-heslin

View GitHub Profile
@ryan-heslin
ryan-heslin / search_error.md
Created January 3, 2022 23:56
How to web search R error messages from within R

Friendly error messages are unfortunately not one of R's strengths. Often, running buggy code will yield something like:

DF <- subset(mtcars, cyl > 4)
df$mpg <- round(df$mpg)

#> Error in df$mpg : object of type 'closure' is not subsettable

Huh? A closure is an R function with an enclosing environment (that is, one that can access the environment where it was defined). df is one such function, which gives the F distribution. In plain English, the error message is saying you can't extract an element from a function as if it were a vector.