Functional programming and unit testing for data munging with R
This book is 70% complete
Last updated on 2017-12-27
About the Book
Most of the time spent working on a project is dedicated to preparing data for analysis. In this book, you will learn how to make this very important part of your work more streamlined and reproducible. We will learn about functional programming, unit testing and documenting your code in an automated way with the R programming language. The end goal is to write a package that contains all the needed functions to make your data tidy. This package will be extremely specific to your own needs and data, so you probably will not want to publish it on CRAN, however you can easily share this package with your colleagues or with your future self. This is especially useful if you are part of a project where you get yearly, quarterly or monthly data and need to repeat the same tasks over and over again. Having a thouroughly tested package makes sure that your fresh data gets tidied without any nasty surprises!
The book is still a work in progress. You can read it for free at www.brodrigues.co/fput. You can show your support by buying it on leanpub for any price, but the version on leanpub will not be always up-to-date. This is because I use bookdown to write the book, and converting the html files generated by bookdown to leanpub's markdown takes some time. However, once I'll finish the book, the version on leanpub will of course be completed and well formatted.
Chapter 1 Why this book?
- 1.1 Important notice
- 1.2 Motivation
- 1.3 Who am I?
- 1.4 Thanks
- 1.5 License
Chapter 2 Introduction
- 2.1 Getting R
- 2.2 A short overview of functional programming
- 2.3 A short overview of unit testing
- 2.4 General recommendations to follow this book
Chapter 3 Functional Programming
- 3.1 Introduction
- 3.2 Mapping and Reducing: the base way
3.3 Mapping and Reducing: the
- 3.4 Basic anonymous functions
- 3.5 Wrap-up
- 3.6 Exercises
Chapter 4 The
- 4.1 Smoking is bad for you, but pipes are your friend
4.2 Getting data into R with
havenand what are tibbles
4.3 Transforming your data with
4.4 Tidy your data with
4.5 Functional programming with
4.6 Special packages for special kinds of data:
- 4.7 Exercises
Chapter 5 Programming with the
Chapter 6 Packages
- 6.1 Why you need your own packages in your life
- 6.2 R packages: the basics
- 6.3 Writing documentation for your functions
- 6.4 Extra files inside your package and dependencies
- 6.5 Unit test your package
6.6 Checking the coverage of your unit tests with
- 6.7 Wrap-up
Chapter 7 Unit testing
- 7.1 Introduction
7.2 Unit testing with the
- 7.3 Actually running your tests
- 7.4 Wrap-up
- 7.5 Exercises
Chapter 8 Putting it all together: writing a package to work on data
- 8.1 Getting the data
8.2 Your first data munging package:
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.