Biplot Coordinates in PCA Analysis
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@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.
