Skip to main content

R for analytics beginners: part 1 – getting started

Adam Englebright22 January 20154 min read
R for analytics beginners: part 1 – getting started

Two years ago, or thereabouts: I was introduced in my statistics lectures to a programming language and software environment called R. I took to it immediately, preferring it by far to the simpler software we’d used before, and also to the proprietary software (SAS, SPSS) we used in addition.

Flash forward to:

2015-01-19_09.48.58

A couple of months ago, sitting in the audience for the talks at MeasureFest, and then we had what was, I think, by broad agreement, the best talk by Ela Osterberger, about using R with the Google Analytics API. It was nice to see someone talking about this, as I’d spent a fair bit of time in the months leading up to it doing exactly this. The talk was excellent, and the slide design was sumptuous, but to the best of my knowledge, none of it was put up online.

Flash forward to:

me_writing_this_1024

Me, right now, writing this (I’m actually writing this on Friday but we’ll probably be publishing next week for better numbers). A little while ago, I was asked for some unsampled data from GA. This can be quite annoying, especially when you bump up against the API limits, and running a million enquiries with the spreadsheets extension or query explorer is just a lengthy, tedious slog. However, there is an easier way!


Once you get the hang of R, you can use it for both simple and complex tasks. That said, it’s also free software, and suffers somewhat from the newcomer-hostility that free software is prone to. I learnt R through a command-line interface, but I already had a little bit of programming experience to smooth the way – some of the other people learning alongside me found it heavier going. However, it can, through judicious use of additional tools, be made much friendlier.

First, you need to download and install the package itself from any of the innumerable mirrors, and then I’d suggest, to ameliorate some of that user-unfriendliness, that you download RStudio, an IDE (integrated development environment) that provides a graphical user interface. In fact, even if you don’t care

*

, it’s probably a good thing to have, as it makes a fair few things easier to do.

Once you’ve installed those two, you need to pick your R Google Analytics package. It may surprise you (it surprised me) to learn there are several of these. They are:

1): RGoogleAnalytics

The package that was most easily discoverable when I was researching this a while back was R Google Analytics, developed by Google employees so arguably the most “official”. Regrettably, I found it at a point when it was rather better-documented than it was now, with the user guide for some reason having been removed from the (there’s still a step-by-step on Daniel Waisberg’s site) but I’ve never been able to get this particular extension working as it should, especially with regards to paginating results so as to bypass the API query limits.

2). rga (lower-case)

rga is much better-documented, and seemed as though it would do everything I wanted it to. Regrettably, I couldn’t get it going (though I know several people who were able to, and swear by it, so your mileage may vary).

3). RGA (upper-case)

Took me a little while to notice this one, because as you can imagine, given that the name is exactly the same but for case, it’s not the easiest thing to search for. This is the one that I’ve settled on for the moment, because it seems to be the one that (for me, anyway) allows easiest access to the data, with the least amount of fuss. It also allows you to query the metadata, management, real-time reporting and multi-channel funnels APIs too, so it has a great deal of versatility and additional functionality.

Once you’ve downloaded R and R Studio, you need to install RGA, which you do by entering into the RStudio console:

install.packages("RGA")

Next time, we’ll be looking at how to actually use the extension.


*though if that’s the case and you’re willing to tackle the command-line interface, this is probably a bit basic for you


Suggested content

Measurelab awarded Google Cloud Marketing Analytics Specialisation

At the start of the year, if you’d asked us whether Measurelab would be standing shoulder to shoulder with Europe’s biggest consultancies by September, we would've been surprised. Not because we don't believe in ourselves, but because these things feel so distant - until suddenly, they’re not. So, here it is: we’ve been awarded the Marketing Analytics Services Partner Specialisation in Google Cloud Partner Advantage. What’s the big deal? In Google’s own words (with the obligatory Zs): “Spec

Will Hayes11 Sept 2025

BigQuery AI.GENERATE tutorial: turn SQL queries into AI-powered insights

BigQuery just got a major upgrade, you can now plug directly into Vertex AI using the new AI.GENERATE function. Translation: your analytics data and generative AI are now best friends, and they’re hanging out right inside SQL. That opens up a whole world of new analysis options for GA4 data, but it also raises some questions: * How do you actually set it up? * What’s it good for (and when should you avoid it)? * Why would you batch the query? Let’s walk through it step by step. Step 1: H

Katie Kaczmarek3 Sept 2025

How to start forecasting in BigQuery with zero training

If you’d told me five years ago that I’d be forecasting product demand using a model trained on 100 billion time points… without writing a single line of ML code… I probably would’ve asked how many coffees you’d had that day ☕️ But its a brand new world. And it’s possible. Let me explain What is TimesFM? TimesFM is a new foundation model from Google, built specifically for time-series forecasting. Think of it like GPT for time, instead of predicting the next word in a sentence, it predicts t

Katie Kaczmarek14 Jul 2025