# Articles by Econometrics and Free Software

### It’s lists all the way down

January 2, 2018 |

Today, I had the opportunity to help someone over at the R for Data Science Slack group (read more about this group here) and I thought that the question asked could make for an interesting blog post, so here it is! Disclaimer: the way I’m doing things here is ... [Read more...]

### Building formulae

December 26, 2017 |

This Stackoverflow question made me think about how to build formulae. For example, you might want to programmatically build linear model formulae and then map these models on data. For example, suppose the following (output suppressed):
```data(mtcars)

lm(mpg ~ hp, data = mtcars)
lm(mpg ~I(hp^2), data = mtcars)
lm(mpg ~I(hp^3), data = mtcars)
lm(mpg ~I(hp^4), data = mtcars)
lm(mpg ~I(hp^5), data = mtcars)
lm(mpg ~I(hp^6), data = mtcars)```
To avoid doing this, one can write a function that builds the formulae: {{... [Read more...]

### Teaching the tidyverse to beginners

December 16, 2017 |

End October I tweeted this: will teach #rstats soon again but this time following @drob 's suggestion of the tidyverse first as laid out here: https://t.co/js8SsUs8Nv— Bruno Rodrigues (@brodriguesco) October 24, 2017 and it generated some discussion. Some people believe that this is the right approach, and ... [Read more...]

### Functional peace of mind

November 13, 2017 |

I think what I enjoy the most about functional programming is the peace of mind that comes with it. With functional programming, there’s a lot of stuff you don’t need to think about. You can write functions that are general enough so that they solve a variety of ... [Read more...]

### Easy peasy STATA-like marginal effects with R

October 25, 2017 |

Model interpretation is essential in the social sciences. If one wants to know the effect of variable x on the dependent variable y, marginal effects are an easy way to get the answer. STATA includes a margins command that has been ported to R by Thomas J. Leeper of the ... [Read more...]

### Why I find tidyeval useful

August 26, 2017 |

First thing’s first: maybe you shouldn’t care about tidyeval. Maybe you don’t need it. If you exclusively work interactively, I don’t think that learning about tidyeval is important. I can only speak for me, and explain to you why I personally ... [Read more...]

### Why I find tidyeval useful

August 26, 2017 |

First thing’s first: maybe you shouldn’t care about tidyeval. Maybe you don’t need it. If you exclusively work interactively, I don’t think that learning about tidyeval is important. I can only speak for me, and explain to you why I personally ... [Read more...]

### Why I find tidyeval useful

August 26, 2017 |

First thing’s first: maybe you shouldn’t care about tidyeval. Maybe you don’t need it. If you exclusively work interactively, I don’t think that learning about tidyeval is important. I can only speak for me, and explain to you why I personally ... [Read more...]

### tidyr::spread() and dplyr::rename_at() in action

July 26, 2017 |

I was recently confronted to a situation that required going from a long dataset to a wide dataset, but with a small twist: there were two datasets, which I had to merge into one. You might wonder what kinda crappy twist that is, right? Well, let’s t... [Read more...]

### tidyr::spread() and dplyr::rename_at() in action

July 26, 2017 |

I was recently confronted to a situation that required going from a long dataset to a wide dataset, but with a small twist: there were two datasets, which I had to merge into one. You might wonder what kinda crappy twist that is, right? Well, let’s take a look ... [Read more...]

### tidyr::spread() and dplyr::rename_at() in action

July 26, 2017 |

I was recently confronted to a situation that required going from a long dataset to a wide dataset, but with a small twist: there were two datasets, which I had to merge into one. You might wonder what kinda crappy twist that is, right? Well, let’s take a look ... [Read more...]

### Lesser known dplyr 0.7* tricks

July 1, 2017 |

This blog post is an update to an older one I wrote in March. In the post from March, dplyr was at version 0.50, but since then a major update introduced some changes that make some of the tips in that post obsolete. So here I revisit the blog post from ... [Read more...]

### Lesser known dplyr 0.7* tricks

July 1, 2017 |

This blog post is an update to an older one I wrote in March. In the post from March, dplyr was at version 0.50, but since then a major update introduced some changes that make some of the tips in that post obsolete. So here I revisit the blog post from ... [Read more...]

### Lesser known dplyr 0.7* tricks

July 1, 2017 |

This blog post is an update to an older one I wrote in March. In the post from March, dplyr was at version 0.50, but since then a major update introduced some changes that make some of the tips in that post obsolete. So here I revisit the blog post from ... [Read more...]

### Make ggplot2 purrr

March 28, 2017 |

I’ll be honest: the title is a bit misleading. I will not use purrr that much in this blog post. Actually, I will use one single purrr function, at the very end. I use dplyr much more. However Make ggplot2 purrr sounds better than Make ggplot dplyr or whatever ... [Read more...]

### Make ggplot2 purrr

March 28, 2017 |

Update: I’ve included another way of saving a separate plot by group in this article, as pointed out by @monitus. Actually, this is the preferred solution; using dplyr::do() is deprecated, according to Hadley Wickham himself. I’ll be honest: the title is a bit misleading. I will not ... [Read more...]

### Introducing brotools

March 27, 2017 |

I’m happy to announce my first R package, called brotools. This is a package that contains functions that are specific to my needs but that you might find also useful. I blogged about some of these functions, so if you follow my blog you might already be familiar with ... [Read more...]

### Introducing brotools

March 27, 2017 |

I’m happy to announce my first R package, called brotools. This is a package that contains functions that are specific to my needs but that you might find also useful. I blogged about some of these functions, so if you follow my blog you might already be familiar with ... [Read more...]

### Lesser known purrr tricks

March 24, 2017 |

purrr is package that extends R’s functional programming capabilities. It brings a lot of new stuff to the table and in this post I show you some of the most useful (at least to me) functions included in purrr. Getting rid of loops with map()
```library(purrr)

numbers <- list(11, 12, 13, 14)

map_dbl(numbers, sqrt)```
`## [1] 3.316625 3.464102 3.605551 3.741657`

### Lesser known purrr tricks

March 24, 2017 |

purrr is a package that extends R’s functional programming capabilities. It brings a lot of new stuff to the table and in this post I show you some of the most useful (at least to me) functions included in purrr. Getting rid of loops with map()
```library(purrr)

numbers <- list(11, 12, 13, 14)

map_dbl(numbers, sqrt)```
`## [1] 3.316625 3.464102 3.605551 3.741657`