Skip to content

Instantly share code, notes, and snippets.

@andreagrioni
Created December 1, 2021 08:42
Show Gist options
  • Save andreagrioni/d0a54503821b4bcd816f665aef1af673 to your computer and use it in GitHub Desktop.
Save andreagrioni/d0a54503821b4bcd816f665aef1af673 to your computer and use it in GitHub Desktop.
# create screeplot with PCAtools package
## find optimum number of PCs to retain
elbow <- PCAtools::findElbowPoint(p$variance)
## set image path
image_filepath <- fs::path(data_dir, glue::glue("img/{bmd_tag}.screeplot.png"))
## open image file
png(image_filepath, width=4, height=4, units="in", res=300)
## create image
PCAtools::screeplot(
p,
components = PCAtools::getComponents(p, 1:10),
vline = elbow)
## close devide target of image
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment