Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Biplot Coordinates in PCA Analysis

Anthony_A
7 - Meteor

I would like to export the coordinates of my variables in the biplot that the PCA analysis produces. 

 

I've opened up the PCA Macro and explored the R code to try to figure out a way to export my coordinates but I'm having trouble. I've been searching how to do this with the prcomp package Alteryx uses but I'm coming up short with the right syntax. 

 

I see the R Tool in the macro has outputs 4 and 5 free. Does anyone have any idea what piece of code I need to add to get the coordinates to export to one of those outputs? Seems like all the work is already done inside the R tool and just an export is needed. I figure after that's straightened out all I need is to add a macro output to the end. 

 

 

Thanks!

 

 

2 REPLIES 2
SeanAdams
17 - Castor
17 - Castor

Hey @Anthony_A 

 

Perhaps someone like @SusanCS may be able to direct you to the right person in the team who works with this kind of R code; or suggest another approach?

Anthony_A
7 - Meteor

@SeanAdams  Thanks!

 

I think I might have figured this out. I copied the PCA macro and added the following to the R tool:

 

 

	# Do the actual analysis
	the.pca <- eval(parse(text = the.call)) #this is from the original Alteryx script

# Section I added
coorddf <- as.data.frame(the.pca$x)
library(dplyr)
finaldf <- tibble::rownames_to_column(coorddf, "VALUE") 
write.Alteryx(finaldf, 5)

coorddf2 <- as.data.frame(the.pca$rotation)
finaldf2 <- tibble::rownames_to_column(coorddf2, "VALUE") 
write.Alteryx(finaldf2, 4) 
#

 

 

I then connected two macro outputs and I am able to get the coordinates of both the row and column PCA's. It's a little sloppy but I've had to switch over to another project I'm working on and will be coming back to this to see if I'm missing anything / could be any improvements. I'm not sure how to incorporate the append components feature in the PCA tool though. 

 

Labels