Frighteningly powerful #rstats combo: mutate() + across() + {tidyselect} helpers 💥 🤯 The syntax may be a bit confusing at first, though. So, here are a couple of simple examples. CODE: gist.github.com/AlbertRapp/043…
Did you like this tweet or the meme? Then, you may also like my other stuff! Follow @rappa753 or subscribe to my biweekly newsletter to stay in touch. Every other week, I share thoughts about dataviz, Shiny web apps and statistics. See you next time! alberts-newsletter.beehiiv.com/subscribe
@rappa753 Yes. For a long time I kept wanting to put my fns outside of across() because I thought of across() as the selector not the doer. But across() holds both the selector and the doer. Once I remembered that I was good to go.
@rappa753 The real fun with `across()` starts when you write functions that let the user supply the tidyselect specification, which the function then defuses and injects into `across()`! If nothing is supplied, a default expression is injected instead. github.com/lhdjung/scruti…
@rappa753 Recently I had problems transforming factors into character. As I selected factors and called as.character() upon then, factors' names were converted to "numeric" strings, weird! It took time to get what I wanted. That said, your code is clear and concise, I liked it!
@rappa753 The scale function does also a good job, but indeed using the mutate(_*) + across syntax in key in R.
@rappa753 You can use mutate_at(), the result is equal.