Blog Archives

My free book has a cover!

January 6, 2017
By
My free book has a cover!

I’m currently writing a book as a hobby. It’s titled Functional programming and unit testing for data munging with R and you can get it for free here. You can also read it online for free on my webpage What’s the book about? Here’s the teaser...

Read more »

Functional programming and unit testing for data munging with R available on Leanpub

December 23, 2016
By

The book I’ve been working on these pasts months (you can read about it here, and read it for free here) is now available on Leanpub! You can grab a copy and read it on your ebook reader or on your computer, and what’s even better is that it is av...

Read more »

Work on lists of datasets instead of individual datasets by using functional programming

December 20, 2016
By

Analyzing a lot of datasets can be tedious. In my work, I often have to compute descriptive statistics, or plot some graphs for some variables for a lot of datasets. The variables in question have the same name accross the datasets but are measured for different years. As an example, imagine you have this situation: data2000 <- mtcars data2001 <-...

Read more »

I’ve started writing a ‘book’: Functional programming and unit testing for data munging with R

November 3, 2016
By

I have started writing a ‘book’ using the awesome bookdown package. In the book I explain and show why using functional programming and putting your functions in your own packages is the way to go when you want to clean, prepare and transform lar...

Read more »

Merge a list of datasets together

July 29, 2016
By

Last week I showed how to read a lot of datasets at once with R, and this week I’ll continue from there and show a very simple function that uses this list of read datasets and merges them all together. First we’ll use read_list() to read all the datasets at once (for more details read last week’s post):

Read more »

Read a lot of datasets at once with R

July 25, 2016
By

I often have to read a lot of datasets at once using R. So I’ve wrote the following function to solve this issue: read_list <- function(list_of_datasets, read_func){ read_and_assign <- function(dataset, read_func){ dataset_name <- as.name(dataset) ...

Read more »

Data frame columns as arguments to dplyr functions

July 17, 2016
By

Suppose that you would like to create a function which does a series of computations on a data frame. You would like to pass a column as this function’s argument. Something like: data(cars) convertToKmh <- function(dataset, col_name){ dataset$col_name <- dataset$speed * 1.609344 return(dataset) } This example is obviously not very interesting (you don’t need a function for this), but it...

Read more »

Careful with tryCatch

June 20, 2016
By

tryCatch is one of the functions that allows the users to handle errors in a simple way. With it, you can do things like: if(error), then(do this). Take the following example: sqrt("a") Error in sqrt("a") : non-numeric argument to mathematical function Now maybe you’d want something to happen when such an error happens. You can achieve that with tryCatch: tryCatch(sqrt("a"), error=function(e) print("You can't take...

Read more »

Unit testing with R

March 30, 2016
By

I've been introduced to unit testing while working with colleagues on quite a big project for which we use Python. At first I was a bit skeptical about the need of writing unit tests, but now I must admit that I am seduced by the idea and by the huge time savings it allows. Naturally, I was wondering...

Read more »

Bootstrapping standard errors for difference-in-differences estimation with R

November 10, 2015
By
Bootstrapping standard errors for difference-in-differences estimation with R

I’m currently working on a paper (with my colleague Vincent Vergnat who is also a Phd candidate at BETA) where I want to estimate the causal impact of the birth of a child on hourly and daily wages as well as yearly worked hours. For this we are using non-parametric difference-in-differences (henceforth DiD) and thus have...

Read more »

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)