draw_biplot | R Documentation |
takes a data frame, performs PCA on the numeric columns, and draws a biplot with a clearly labeled calibrated axis for one of the original numeric columns. The first non-numeric column is used to label PC scores (points).
draw_biplot(
data,
key_axis = "none",
ticklab = NULL,
project = TRUE,
scale = TRUE,
fix_sign = FALSE,
points = TRUE,
point_labels = TRUE,
arrows = TRUE,
mult = NULL,
vector_colors = c("deepskyblue3", "brown2"),
point_color = "grey40",
point_size = 1.25,
label_size = 2.75
)
data |
data.frame or object that can be coerced to one. PCA will be performed on numeric columns. The first non-numeric column will be used to label PC scores (points). |
key_axis |
character indicating the column name of the axis to calibrate. If none is specified, no axes will be calibrated. |
ticklab |
vector of values indicating axis breaks and tick labels for calibrated axis. If not specified, five evenly spaced round values will be chosen by |
project |
logical indicating whether projection lines should be drawn from PC scores to PC vectors. Defaults to |
scale |
logical passed to the |
fix_sign |
logical indicating whether the signs of the loadings and scores should be chosen so that the first element of each loading is non-negative. Defaults to |
points |
logical indicating whether to plot principal component scores. Defaults to |
point_labels |
logical indicating whether to plot point labels. Defaults to |
arrows |
logical indicating whether to plot principal component loading vectors. Defaults to |
mult |
(NULL) numeric value used to scale the length of the rotation vectors, in effect creating secondary axes with different scales than the primary axes, although the secondary axes are not shown. If not specified, the factor is set to the ratio of 75th percentile distance between the scores and the origin to the length of the longest vector. |
vector_colors |
= vector of two colors, the first for the non-calibrated vectors and the second for the calibrated axis (and vector). Defaults to |
point_color |
= color for points and point labels. Defaults to |
point_size |
= point size. Defaults to |
label_size |
= label size. Defaults to |
This function was developed mainly for teaching and learning purposes. There are many options for drawing biplots. The main contributions of this one are ease of use and option to calibrate one of the axes. Calibration calculations are performed by calibrate::calibrate()
.
(to be added)
swiss$country <- rownames(swiss)
draw_biplot(swiss, key_axis = "Agriculture")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.