Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Object of type 'closure' is not subsettable

Talk developed for rstudio::conf 2020, January 27 - 30, 2020 in San Francisco
by Jenny Bryan
Twitter: @jennyBryan
GitHub: @jennybc

Your first "object of type 'closure' is not subsettable" error message is a big milestone for an R user. Congratulations, if there was any lingering doubt, you now know that you are officially programming! Programming involves considerably more troubleshooting and debugging than many of us expected (or signed up for). The ability to solve your own problems is an incredibly powerful stealth skill that is worth cultivating with intention. This talk will help you nurture your inner problem solver, covering both general debugging methods and specific ways to implement them in the R ecosystem.

Link to this repo is a shortlink to HERE


Slides on SpeakerDeck

Slides as PDF file here in this repo


The original rstudio::conf talk was live-streamed and recorded. Video is available here:

Credits and resources

Annotated and hyperlink-y list of resources mentioned in the slides, in roughly the same order.

Restart R, often, and don't save/reload .Rdata.

This recommendation is explored more thoroughly in Save source, not the workspace. This mindset works best as part of a more holistic "project-oriented workflow", which is described in adjacent sections of What They Forgot to Teach You About R.

One of the most useful things I’ve learned from hanging out with (much) better programmers: don’t wring hands and speculate. Work a small example that reveals, confirms, or eliminates something.

I'm paraphrasing my own tweet:

The reprex package:

RStudio webinar about reprex: Help me help you: Creating reproducible examples with reprex

The REPREX section features several illustrations by Christine Kuper.

We gratefully acknowledge Michelle Rial and her charts for an inspiring visual style.

The example of how a wild-caught puzzle evolves into a good reprex was kindly donated by Brooke Watson Madubuonwu.

Story concluded in tidyverse/dplyr#4094.

GitHub search for Hadley's "slightly more minimal reprexes": [more minimal reprex NOT advice user:tidyverse user:r-lib user:hadley involves:hadley is:issue] more minimal reprex NOT advice user:tidyverse user:r-lib involves:hadley is:issue

Presentation of a rather intimidating R message was inspired by a Far Side comic from Gary Larson. You know ... the one about Ginger the dog and "blah blah".

The Far Side very recently got a real online home: However, last time I checked, this particular comic isn't there (yet). Hopefully it will appear one day and I can link to it.

All the code snippets from the fruit_avg() debugging example are in R/.

Debugging with RStudio

rlang's functions for Errors, conditions, and backtraces

Video of a tiny room hidden behind an electrical outlet is from Mozu Studios:

The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at and repair.

Quote attributed to Douglas Adams, but I am not sure of the original source.

The tidyverse and r-lib packages have an aspirational and developing style guide for error messages:

Static code snippets prepared with the reprex package, using venue = "rtf", which relies on highlight.

GIFs of code prepared with r-lib/asciicast plus asciinema/asciicast2gif.

This talk benefitted greatly from:

Image credits

Do same thing again:
Ocean horizon background:
Calm sea background:
Coral reef background:
Seaweed background:
Corn field:
On/off key:
Sunlight under water background:
Garnishing with sauce:
Death certificate (modified): Public Domain,
Sunlight under water background: Washing pot:
The Night King: (probably copyright HBO)
Autopsy painting by Rembrandt: Public Domain,
Gray cube abstract wallpaper vector art


Talk about general debugging strategies. How to be less confused and frustrated.







No releases published


No packages published