Guest User

Untitled

a guest
Oct 15th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. set.seed(1)
  2. dat <- data.frame(
  3. Diet = sample(1:2),
  4. Outcome1 = sample(1:10),
  5. Outcome2 = sample(11:20),
  6. Outcome3 = sample(21:30),
  7. Response1 = sample(31:40),
  8. Response2 = sample(41:50),
  9. Response3 = sample(51:60)
  10. )
  11.  
  12. ir.pca <- prcomp(dat[,3:5], center = TRUE, scale. = TRUE)
  13.  
  14. summary(ir.pca)
  15.  
  16. loadings <- ir.pca$rotation
  17.  
  18. scores <- ir.pca$x
  19.  
  20. correlations <- t(loadings)*ir.pca$sdev
  21.  
  22. dat2 <- as.data.frame(dat)
  23. ggbiplot(ir.pca, choices=c(1,2), # creates a plot with ellipse
  24. groups=dat2[,1],
  25. obs.scale = 1,
  26. var.scale = 1,
  27. ellipse = TRUE)
Add Comment
Please, Sign In to add comment