Master Your R Code Management with TODOr: A Comprehensive Guide
Written on
Chapter 1: Introduction to TODOr
Managing comments and reminders in your R code can be a daunting task. Thankfully, the TODOr package is here to help streamline this process. With TODOr, you will no longer overlook important notes like "FIXME" or "TODO."
Photo by ThisisEngineering RAEng on Unsplash
Chapter 2: The Benefits of Using TODOr
What exactly can TODOr do for you? Have you ever found yourself saying:
“I need to remember to address this bug…”
For example:
# FIXME: This doesn't work
#> Error in mean[1] : object of type 'closure' is not subsettable
You might intend to revisit this issue later, but often these reminders get lost in a massive codebase. With TODOr, you can effectively manage these reminders to reduce technical debt. It scans entire files, projects, or packages to locate all your comments, presenting them in a clear, organized list.
The list details the type of comment, its specifics, the file it’s in, and the line number. Clicking on an item in the list will direct you to the precise line that requires your attention!
To harness this tool, simply run:
todor::todor()
Chapter 3: Understanding Default Settings
By default, TODOr identifies all comments marked with specific keywords (like “TODO” and “FIXME”) across your entire R project, as long as you have a .Rproj file in your working directory.
You might be thinking, “Do I really need to see all comments? I’m only interested in my TODOs.”
Rest assured, TODOr filters comments based on designated keywords:
Image by Author
Chapter 4: Customizing Search Parameters
Beyond the defaults, TODOr allows you to search specific files:
todor::todor_file("my_file.Rmd")
Or even an entire R package:
todor::todor_package()
If you’re dealing with a vast codebase, such as ggplot2, you might want to narrow your focus. You can specify which types of comments to include by passing a vector to the function:
todor::todor(c("TODO", "FIXME"))
This customizes your search to only return the comments that matter most to you.
What if you have specific markers you’d like to track? For instance, if you want to tag comments with team member names, you can define a custom list of patterns using the options() function:
options(todor_patterns = c("FIXME", "TODO", "BRYAN"))
Now, comments marked with your name will be recognized by TODOr.
Image by Author
Chapter 5: Expanding Beyond R Files
TODOr isn’t limited to just .R files. You can configure it to search through various file types, and you can adjust this with the options() function:
Image by Author
For example, if you want to include RMarkdown files, set:
todor_rmd = TRUE
This will enable the search through both code chunk and markdown comments.
Chapter 6: Conclusion and Resources
In summary, implementing TODOr in your workflow can greatly enhance your efficiency in managing comments within your code. I've personally utilized this package in various projects, finding it invaluable for keeping track of my notes.
If you prefer a visual overview of this package, check out the following video:
For additional resources and all the code I used for this review, visit my GitHub repository:
tallguyjenks/RPackageReviews
If you enjoy exploring R packages, be sure to check out my previous review on the Patchwork package, which simplifies data visualization layouts in R.