Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Network Graphs in Tableau, using Alteryx

Karthik24
7 - Meteor

I am looking to prepare data for network analysis in Alteryx using R studio via Igraph library.

I used the code below to produce X and Y values but get the following Error.

 

library("igraph")

nodes<-read.Alteryx("#1", mode="data.frame")
edges<-read.Alteryx("#2", mode="data.frame")


net<-graph.data.frame(edges,nodes,directed=T) 

 

layout<-layout_with_fr(graph)

df<-data.frame(layout)
write.Alteryx(df,1)

 

------------------------------------

Error in 'net<-graph.data.frame(edges,nodes,directed=T) '

excecution halted.

 

Can anyone provide a guidance on how to produce Network Graph Data.

11 REPLIES 11
Christina_H
14 - Magnetar

I've hardly used R, but I have experimented with using it for networks.  Here's the code I used:

x<-read.Alteryx("#1", mode="data.frame")

library("igraph")

g<-graph.data.frame(x,directed=TRUE)
d = data.frame(
vertex = vertex_attr(g),
layout = layout.fruchterman.reingold(g),
betweenness = betweenness(g),
degreeout = degree(g,mode="out"),
degreein = degree(g,mode="in"),
degreeall = degree(g,mode="all"),
closeness = closeness(g),
pagerank = page.rank(g)$vector,
evcent = evcent(g)$vector,
hub = hub.score(g)$vector,
authority = authority.score(g)$vector,
trans = transitivity(g)
)

write.Alteryx(as.data.frame(d),1)

 

The data going in has 3 columns, [from] for the source node, [to] for the target node, and [Edge_Weight] (although I have no idea if the R tool uses that!)

FinnCharlton
13 - Pulsar

Hi @Karthik24 , couple of things to try,

 

R Tools are very sensitive to data types, make sure all your numeric data types are Doubles.

 

If this is using my macro from Alteryx Gallery, someone recently pointed out to me that the string inputs in this macro are set to a small size (11). Try editing the macro by adding a 'Select' tool after the inputs and increasing the size of the fields.

 

Also, it looks like the next line, "layout<-layout_with_fr(graph)" is calling a variable (graph) which is not defined. I imagine this is supposed to be "layout<-layout_with_fr(net)".

 

Hope this helps!

Karthik24
7 - Meteor

@FinnCharlton Thanks for the response. I tried the above code from https://www.thedataschool.co.uk/finn-charlton/ne Yes it's supposed to be 'net' my bad. Firstly I am not using macros. I just connected using your data in a text file and try it out. I am getting the same error while generating the igraph objects. I am following the exact method mentioned in the blog.

FinnCharlton
13 - Pulsar

@Karthik24 Have you installed the igraph package? Go to Program Files\Alteryx and find 'R.exe', then enter install.packages("igraph").

Karthik24
7 - Meteor

@Christina_H Thanks for your response the code perfectly worked fine. But I am looking for just X and Y axes values to plot the network graph in Tableau along with Index. Is there a solution just to achieve that? 
I have a set of pre-processed words and a list of Topics that ties those words, I want Topic to act as Node and words as Edges.

Christina_H
14 - Magnetar

As I said I'm not at all an expert in R, but that's exactly what I've experimented with using this for.  The output includes the x and y coordinates, which I then join back to the full set of data before exporting to Tableau.  I expect some of that code can be dropped to still achieve that outcome.

Karthik24
7 - Meteor

@FinnCharlton Sorry to bother you with multiple questions. I think there is no igraph installed and that is causing the error. However, when I try to install it it says 

Error in install.pacakages("igraph") :
could not find function "install.packages"

 

 

One of the solutions I found is to find .Rprofile and delete it, but I am unable to find it.

 

FinnCharlton
13 - Pulsar

@Karthik24, might be a stupid question but have you spelt install.packages correctly?

 

Karthik24
7 - Meteor

Yes, 

 

install.packages("igraph")
Warning in install.packages("igraph") :
'lib = "C:/Program Files/Alteryx/R-4.1.3/library"' is not writable
Would you like to use a personal library instead? (yes/No/cancel)

Labels