How to build an R line chart, step by step (and the importance of process)

Last week, I was talking to a guy who’s learning analytics, coaching him on what skills to learn next and helping him plan a career path. He’s a smart guy with an analytical background and minor coding experience, but he’s new to R.

Towards the end of the conversation, I asked him, “what’s the biggest challenge you have right now, learning analytics.”

His response? “The code is intimidating.”

I get it. Learning R can seem daunting.

Here’s an example. Take the following R line chart.

This a is plot of China CO2 emissions data (from The World Bank) made with R’s ggplot2 package.

Here’s the code that produced it: