emilyriederer / website

Blog / website repo
https://emilyriederer.com
3 stars 1 forks source link

Building a team of internal R packages | Emily Riederer #17

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Building a team of internal R packages | Emily Riederer

On the jobs-to-be-done and design principles for internal tools

https://emilyriederer.netlify.app/post/team-of-packages/

MilesMcBain commented 3 years ago

Big smile on my face here. I think my team is on a very similar track to you, maybe a little behind. Definitely have built a few of these team members including some that are like siblings of your examples!

I think the next big thing for us is incorporating some standards into our field names. I already shared your {convo} post with the team, I can see that type of thing really working for us.

Also love your take on vingettes! Due to their domain specificity, effort put into README or vignettes reaps so much more value in an internal context. And I've found they generate so much more feedback than regular open source packages.

One tidbit I thought you might like, though you may already know: in ggplot2 it's possible to write a function that returns ggproto objects in a list and that list plays nicely with +.

So I have things very much like your viz_cohort, but tend to write them like:

layer_cohort <- function(data, 
                       time = "MONTHS_SUBSCRIBED", 
                       metric = "IND_ACTIVE",
                       group = "COHORT",
                       ...) {

list(
    aes(x = .data[[time]], 
        y = .data[[metric]],
        group = .data[[group]]),
    geom_line(aes(...)),
    my_org_theme()
)
}

Which makes these domain specific plots a little more composable. Like custom geoms but without all the ggproto hassle:

data %>%
ggplot(aes(blah blah)) +
geom_something_else() +
layer_cohort(data = other_data, tweak1, tweak2)

Your way is of course fine and proper. Just sharing because I felt compelled to offer something up for the pleasure of reading this!

emilyriederer commented 3 years ago

Thanks so much, @MilesMcBain ! really appreciate the kind words, and it's very validating to hear that you and your team have converged on some similar standards as well. Like so many things, I think there is a "theory" to internal packages, but it's so much harder for all of us devs to learn from each other and share them in that space.

Also, I really appreciate this tip / example on viz functions! I'd never thought of doing that, and that's definitely fantastic. I love that it makes the incremental functions even more atomic for composition. I definitely tend to steer clear of custom geoms internally just since they can be more confusing to newer devs / users, but this seems like a great way to get the best of both worlds. Can't wait to try it out! 🤩

Thanks again for commenting -- this is the best type of comment. It's always so exciting to me when people take the time to share alternative ideas and approaches.

openbakk commented 2 years ago

Perfect