Category Archives: TidyX Screen Cast

TidyX Episode 183: Within-group regression using {purrr}

Sometimes you have a number of groups/strata in your data and you want to fit the same model structure to each of them independently. While you could write a for() loop to handle this, the issue becomes more complicated if your data all of a sudden has new groups/or strata (for example, maybe this model is working inside of an on going pipeline, where data is continuously being collected and modeled). Additionally, for() loops can get cumbersome, lead to a lot of copying and pasting, and potentially introducing errors in code (which can sometimes be hard to identify and debug). One way to circumvent these issues is to use the {purrr} package’s suite of map() functions. By splitting the data on the groups/strata one can apply the linear model function (or any model function, for that matter) to each of the groups and quickly obtain results that can be used down stream. This week, Ellis Hughes and I show you how to accomplish this task!

To watch our screen cast, CLICK HERE.

To access our code, CLICK HERE.

TidyX Episode 181 – Likert Scales & Planned Comparisons Function

This week, Ellis Hughes and I continue talking about ways to use for() loops and custom functions to speed up your work. Here, we take some data from the TidyTuesday project on coffee ratings. This data is based on a type of Likert scale where the respondents are scoring their coffee expertise from 0 to 10. The data is stratified by age groups. While there are a number of ways of analyzing Likert scale data (and a lot of disagreements), we felt this was just a useful data set to quickly grab and show how to leverage a for() loop to make comparisons in coffee expertise between age groups, using a t-test.

To watch the screen cast, CLICK HERE.

To access our code, CLICK HERE.