install.packages(
"https://github.com/leripio/R4ER2data/releases/download/v1.0.0/R4ER2data_1.0.0.tar.gz",
repos = NULL,
type = "source"
)
R for Economic Research (2e)
Preface to the Second Edition
Two years have passed since the first edition of R for Economic Research, and I’m deeply grateful for how far the project has come. The book has now received over 40,000 views from readers in more than 50 countries, and I’ve had the privilege of hearing from many readers who found it useful in their work. Even people I greatly admire have taken notice — for instance, Rami Krispin featured it in his weekly LinkedIn newsletter. These moments have meant a lot to me and motivated me to take the project further.
I’ll admit that right after publishing the first edition, I doubted whether I’d ever start a new R project. I wondered if R might soon become obsolete, and at the 2024 Posit Conference I even asked Hadley Wickham whether we should stick with R or switch to Python as soon as possible. His response was encouraging, but the real reassurance came from what followed: the R ecosystem has continued to grow, modernize, and integrate with the latest technologies. More recently, Hadley’s A personal history of the tidyverse reinforced that perspective — not only telling the story of the tidyverse, but also pointing to an exciting future for R as a whole. Like him, I still love R, love programming, and love contributing to this vibrant community.
At one point, I thought it would be more exciting to begin an entirely new book. But I soon realized that it would be even more valuable to make R for Economic Research an improved and enduring resource — one that readers could still rely on years later, and hopefully for many more to come. This second edition updates the original chapters, adds new ones inspired by the challenges I’ve faced since then, and improves readability by following the Tidyverse style guide more closely.
On the technical side, readers will find new chapters that fill gaps from the first edition — some intentionally left aside back then, others that I’ve only explored more recently. They share a common goal: to offer tools for handling high-frequency data, and enabling more flexible modeling. I hope these additions open new opportunities for your work.
Another improvement I’m particularly proud of is the creation of an accompanying R package - R4ER2data
- that contains all the datasets used in the book’s exercises. This was something I had wanted to include in the first edition but only managed to accomplish now. In the same spirit of enhancing reproducibility, the book now also relies on the renv
package for library management, which should further reduce compatibility issues and make it easier for readers to replicate the exercises. If you encounter any issues, please refer to the GitHub issues section where you can report problems or check if they’ve already been addressed.
Preface to the First Edition
Over the past years, I’ve received many messages asking what I consider to be the most important subjects to learn when starting a career in economic research. R for Economic Research is my contribution to those who already have some familiarity with R programming but still lack the tools needed to carry out professional economic analysis. This is an intermediate-level book designed to offer shortcuts for tackling a variety of tasks, along with valuable references for those interested in exploring more complex topics in depth.
The reasoning behind the book can be summarized as follows:
Modern economic research requires a solid grasp of programming.
With more and more data now accessible via APIs, it’s possible to automate high-quality analyses almost instantly using efficient techniques. Moreover, unstructured data only becomes meaningful when properly processed. I chose R because I genuinely believe the Tidyverse offers an unparalleled data science workflow.
But programming alone isn’t enough.
I’ve interviewed several candidates who were highly proficient coders but lacked a basic understanding of applied time series methods. Many, for example, didn’t know how to perform seasonal adjustments or how to deflate nominal values into real ones. Filling these gaps is essential.
A solid understanding of forecasting is vital.
And I’m not referring to state-of-the-art machine learning models. In most cases, traditional statistical methods are more than enough. The real skill lies in setting up a workflow that produces reliable forecasts.
Economic modeling is at the heart of applied research.
Estimating relationships between economic variables and producing projections is the core of what economic researchers do. While this topic requires theoretical and practical training that goes beyond the scope of this book, I believe it’s valuable to show how to set up the basic framework for such models.
Taking it to the next level.
Some tools can significantly expand your capabilities. Learning how to build and estimate state-space models is, without a doubt, a major step toward becoming a senior analyst.
I truly hope you enjoy reading this book and that it proves helpful to your career.
Feel free to reach out with suggestions or feedback via email — I’d love to hear from you.
Acknowledgements
First and foremost, I’d like to thank all those who generously contribute to the R community — whether by developing packages, sharing free content, or answering questions on Stack Overflow. I owe much of my learning to you, and this book is, to a large extent, my way of giving back.
I also want to thank my therapist, Fátima Costa, for all the emotional support throughout this journey. Writing this book meant making myself vulnerable in many ways — sharing my skills publicly, writing in a language that isn’t my native tongue, and more. I certainly feel more confident now than when I first started.
While I handled most of the technical aspects of this book on my own, I was lucky to count on the help of some generous people along the way. Fernanda Boldrini, in particular, offered thoughtful and sensitive suggestions that helped shape the final version of the cover. Her delicate way of contributing made me feel more at ease and confident with the result — and I’m truly grateful for that.
Finally, I dedicate this book to my family:
To my mother, Célia Leripio, and my father, João Bosco Gomes, who did everything they could to provide me with the education that made this possible.
To my sister, Nathália Leripio, and her newborn son, João Gabriel Leripio — to whom I hope to set good examples.
Data
The datasets used throughout this book are available in the companion R package R4ER2data
.
You can install the package directly from GitHub using the following command:
Alternatively, if you prefer the development version:
::install_github("leripio/R4ER2data") devtools
After installation, simply load the package with library(R4ER2data)
to access the datasets used in the exercises.
Citation
Leripio, J. Renato. (2025) R for Economic Research: Essential tools for modern economic analysis. Second Edition (September 2025). Available at http://book.rleripio.com
License
R for Economic Research: Essential tools for modern economic analysis by J. Renato Leripio is licensed under Attribution-NonCommercial-ShareAlike 4.0 International