Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Sample code to plot PCs coefficients associated with variables in the dataset. See for more info.
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