Git Product home page Git Product logo

debugging's Introduction

Object of type 'closure' is not subsettable

Talk developed for rstudio::conf 2020, January 27 - 30, 2020 in San Francisco
by Jenny Bryan
jennybryan.org
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

rstd.io/debugging is a shortlink to HERE

Slides

Slides on SpeakerDeck

Slides as PDF file here in this repo

Video

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

https://resources.rstudio.com/rstudio-conf-2020/object-of-type-closure-is-not-subsettable-jenny-bryan

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: https://twitter.com/JennyBryan/status/952285541617123328


The reprex package: https://reprex.tidyverse.org

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: https://www.thefarside.com. 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:

https://style.tidyverse.org/error-messages.html


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

Fret: https://unsplash.com/photos/OsC8HauR0e0
Do same thing again: https://unsplash.com/photos/uxUUENpp01I
Diver: https://unsplash.com/photos/wVvxjiLJr-g
Ocean horizon background: https://unsplash.com/photos/sYzFIusQp3Q
Calm sea background: https://unsplash.com/photos/IZ01rjX0XQA
Coral reef background: https://unsplash.com/photos/T1Wru10gKhg
Seaweed background: https://unsplash.com/photos/nAkC-KS444M
Orchid: https://unsplash.com/photos/Ug6z9PCwr58
Corn field: https://unsplash.com/photos/nCQXxsSg3oo
On/off key: https://unsplash.com/photos/cw_uvISXkCI
Sunlight under water background: https://unsplash.com/photos/K785Da4A_JA
Garnishing with sauce: https://unsplash.com/photos/YaiY50wzWzI
Death certificate (modified): Public Domain, https://commons.wikimedia.org/w/index.php?curid=214170
Sunlight under water background: https://unsplash.com/photos/K785Da4A_JA Washing pot: https://unsplash.com/photos/-VhH4S1Lur8
The Night King: https://cnet4.cbsistatic.com/img/vugy5MvUVBvwcJf0JvKIBd1RwJE=/1200x675/2019/04/22/2b2fee8d-111a-4d19-ae83-4e61899cfd47/1nightking.jpg (probably copyright HBO)
Autopsy painting by Rembrandt: https://www.mauritshuis.nl/en/explore/the-collection/artworks/the-anatomy-lesson-of-dr-nicolaes-tulp-146/detailgegevens/ Public Domain, https://commons.wikimedia.org/w/index.php?curid=64281722
Gray cube abstract wallpaper vector art https://unsplash.com/photos/1CVy8JStf3A

debugging's People

Contributors

jennybc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.