Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Sample code to plot PCs coefficients associated with variables in the dataset. See http://tgmstat.wordpress.com/2013/11/28/computing-and-visualizing-pca-in-r/ for more info.

View loading_plot.R
1 2 3 4 5 6 7 8 9 10 11 12
require(ggplot2)
 
theta <- seq(0,2*pi,length.out = 100)
circle <- data.frame(x = cos(theta), y = sin(theta))
p <- ggplot(circle,aes(x,y)) + geom_path()
 
loadings <- data.frame(ir.pca$rotation,
.names = row.names(ir.pca$rotation))
p + geom_text(data=loadings,
mapping=aes(x = PC1, y = PC2, label = .names, colour = .names)) +
coord_fixed(ratio=1) +
labs(x = "PC1", y = "PC2")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.