Publications by Maëlle's R blog on Maëlle Salmon's personal website
The real reset button for local mess fom tests: withr::deferred_run()
Following last week’s post on my testing workflow enhancements, Jenny Bryan kindly reminded me of the existence of an actual reset button when you’ve been interactively running tests that include some “local mess”: withr::local_envvar(), withr::local_dir(), usethis::local_project()… The reset button is withr::deferred_run(). It is documen...
2552 sym R (1117 sym/5 pcs)
Two recent enhancements to my testing workflow
I spend a lot of quality time with testthat, that sometimes deigns to praise my code with emojis, sometimes has to encourage me. No one gets it right on the first time apparently? Anyway, in honor of testthat 3.2.0 release 🎉 👏, I’d like to mention two small things that improved my testing workflow a whole lot! Running one single test at a t...
2446 sym R (159 sym/1 pcs)
How to translate your package’s messages with {potools}
In November I’ll give a talk about multilingualism in R at the Spanish R conference in Barcelona (😍). I can’t wait! Until then, I need to prepare my talk. 😅 I plan to present the rOpenSci “multilingual publishing” project but also other related tools, like potools. In this post, I’ll walk you through a minimal example of using potoo...
4443 sym R (1590 sym/9 pcs)
3 R functions that I enjoy
Straight from my sticky note, three functions that I like a lot, despite their not being new at all… But maybe new to some of you? sprintf(), the dependency-free but less neat “glue” Imagine I want to tell you who I am. I could write name <- whoami::fullname() github_username <- whoami::gh_username() glue::glue("My name is {name} and you'll ...
2547 sym R (674 sym/3 pcs)
R functions that shorten/filter stuff: less is more
My sticky note is full! And luckily all functions on it can be squeezed into a similar topic: making things smaller! Make lists smaller with purrr::compact(), purrr::keep(), purrr::discard() Once upon a time there was a list (isn’t this the beginning of all R scripts?!) my_list <- list( name = "Maëlle", city = "Nancy", r_problems_encounte...
2936 sym R (1092 sym/10 pcs)
Three (four?) R functions I enjoyed this week
There are already three functions of note on a piece of paper on my desk, so it’s time to blog about them! How does this package depend on this other package? pak::pkg_deps_explain() The pak package by Gábor Csárdi makes installing packages easier. If I need to start working on a package, I clone it, then run pak::pak() to install and update it...
3799 sym R (1842 sym/3 pcs)
Reducing my for loop usage with purrr::reduce()
I (only! but luckily!) recently got introduced to the magic of purrr::reduce(). Thank you, Tobias! I was told about it right as I was unhappily using many for loops in a package1, for lack of a better idea. In this post I’ll explain how purrr::reduce() helped me reduce my for loop usage. I also hope that if I’m doing something wrong, someone wi...
3078 sym R (3614 sym/9 pcs)
Three useful (to me) R notions
Following my recent post on three useful (to me) R patterns, I’ve written down three other things on a tiny sticky note. This post will allow me to throw away this beaten down sticky note, and maybe to show you one element you didn’t know? nzchar(): “a fast way to find out if elements of a character vector are non-empty strings” One of my f...
3441 sym R (398 sym/2 pcs)
Three useful (to me) R patterns
I’m happy to report that I thought “oh but I know a better way to write that code!” a few times lately when reading old scripts of mine, or scripts by others. It’s a good feeling because it shows progress! I’ve tooted about all three things I’ll present in this post: After reading Julia Evans’ post about blogging, I decided to train t...
2878 sym R (624 sym/9 pcs)
git and GitHub in R for the casual user
If you’ve been taught git and GitHub but practice so rarely that you’re discouraged, what should you do to re-start more easily? Let’s imagine you have to, or really want to, use git and GitHub for your next analysis project. Here’s what I would recommend… I assume you already own a GitHub account. If not, refer to happygitwithr guidanc...
8476 sym