Building wildvizR: My Journey from Analysis to R Package

Creating the wildvizR package has been one of the most enriching experiences of my data science learning journey. What began as a simple analysis in an R Markdown file during a previous assignment gradually evolved into a full-featured R package, developed with purpose and creativity. For this final assignment with Professor Alon, I continued using the same cleaned California wildfire dataset, but instead of starting from scratch, I built upon my earlier work to deepen and expand the project. The result is a reusable toolkit that includes functions to summarize wildfire damage by year, flag major incidents based on customizable thresholds, inspect data structure and missing values, and generate choropleth maps of financial loss across California counties.

Please 📂Check out my complete code on GitHub!

The core purpose of the wildvizR package is to transform raw wildfire data into meaningful summaries and compelling visual narratives. One key improvement was replacing my original tagging function with a more elegant version that uses the power of dplyr::filter() while offering flexibility to either tag or filter incidents. I also introduced a new clean_column_names() function to standardize variable names — a small but crucial step that made every downstream function more readable and robust. Throughout development, I wrote and tested each function in isolation, updated global variables, documented everything with roxygen2, and created a vignette that ties the entire workflow together in a clear, educational format. The package structure mirrors professional best practices, and each component — from the DESCRIPTION file to the NAMESPACE, data folder, vignette, and README — serves a distinct role.

The debugging process was also a key moment in this project. Thanks to the dedicated module we completed previously in the semester, I learned how to interpret RStudio’s error messages, track down the root causes, and use diagnostic tools to isolate bugs. This foundation made it much easier to identify issues during package development, like mismatched column names or failing vignette builds, and instead of feeling stuck, I felt equipped. With ChatGPT’s guidance acting as a real-time collaborator, I explored each warning and error message with curiosity rather than frustration. The result was not only a functional package, but a cleaner, better-structured one, and a deeper confidence in my ability to troubleshoot and think like a developer.

Please 📂Check out my complete code on GitHub!

Here is a collage of my last five errors (there were many more errors), I was able to debug and understand the context with the aid of ChatGPT

🛠️ 1. Error: could not find function “%>%”

Context:
When building the vignette, R couldn’t find the pipe operator %>%.

Fix:
Loaded dplyr explicitly in the setup chunk of the vignette.

library(dplyr)


🛠️ 2. Error: There is no package called ‘wildvizR’

Context:
Clicked “Knit” on the .Rmd Instead of building it as a vignette.

Fix:
Ran: devtools::install(build_vignettes = TRUE)


🛠️ 3. Error: could not convert ‘date’ to class “Date”

Context:
Your cleaned column names changed "Date" to date, and as.Date() failed due to unknown format.

Fix:
Specified the format explicitly: as.Date(date, format = “%m/%d/%Y”) # or appropriate format


🛠️ 4. Error: could not find function “summarize_wildfire_damage”

Context:
While building the vignette, your function wasn’t exported properly.

Fix:
Added @export To the function’s roxygen2 block and re-ran:

devtools::document()


🛠️ 5. NOTE: ‘sf’ and ‘stats’ in Imports, but not imported

Context:
R CMD check noted that sf and stats were listed in DESCRIPTION but not called explicitly.

Fix (optional):
You could remove them from DESCRIPTION or use:

#’ @importFrom sf st_as_sf

#’ @importFrom stats filter


Final Thoughts

I genuinely learned a lot from this project, and surprisingly, I enjoyed doing it. I’d honestly do it all over again just for how satisfying it felt to watch everything come together. Most of all, I’m just thrilled that I can finally understand what R errors are telling me — and fix them without panicking. Yay for progress, persistence, and learning the language of R! 🎉💻

Leave a comment