Alteryx for R Souls: a quick introduction

by Gwilym Lockwood

I’m an R Soul, I’ve always been an R Soul, and I’m not ashamed to admit it. The first time I saw the way Alteryx looked on the screen, I wasn’t impressed. Drag and drop? Manual selection? Source code hidden underneath a GUI? Nah, I’m not having that, that’s why I abandoned things like SPSS in the first place.

Except that Alteryx works. Really well.

I found I could understand Alteryx quicker if I see it as a direct, visual translation of the data munging code I’d normally use. A function in R is the same as a tool in Alteryx, and each line in R is a node in Alteryx.

For example: in R, I might want to get a .csv file and read it in, like this:

df <- read.csv("dataforthatbankthatwouldkillmeifileakedit.csv", stringsAsFactors=FALSE)

In Alteryx? Just drag and drop the input data tool into the view, and choose the file:


Another bonus is that while R is a bit finickity about variable names, Alteryx doesn’t really care if there are spaces in your column headers.

The rest of the data munging looks similar. Handily, the <code>filter()</code> and <code>select()</code> functions from the dplyr package do the same thing as the filter and select tools in Alteryx. There’s also the useful autofield tool, which looks through the data and decides what the best format would be. No more strings as factors, or numbers as strings, or anything that trips up the analysis later on. There’s the output tool, which is just like write.csv() or write.table().

So, some R code that might look like this…

df <- read.csv("dataforthatbankthatwouldkillmeifileakedit.csv", stringsAsFactors=FALSE)
the_hit_list <- df %>%
filter(money_they_have > 500) %>%
filter(send_the_bailiffs != "No") %>%
select(client, balance, send_the_bailiffs, where_to)
write.csv(the_hit_list, "the_hit_list.csv")

…would look like this in Alteryx:


Then, you just press the green play button, and it runs the workflow:


With Alteryx, you can save straight to .tde for whacking into Tableau right away. In R, you’d have to do all this.

Stay tuned for more Tableau/Alteryx for R Soul tips!