#| label = "getLibs"
library(tidyverse)
library(broom)
library(knitr)
#| label = "{{DataName}}.pc"
{{DataName}}.pc = {{DataName}} |>
  select(where(is.numeric)) |> 
prcomp(center=TRUE, scale=FALSE)
#| label = "GetVariances"
{{DataName}}.pc |>
  tidy(matrix = "pcs") |> 
kable(caption="Principal Component contributions for the {{DataName}} data.")
#| label = "ScreePlot{{DataName}}.pc",
#| fig.cap = "Scree plot for the principal components analysis of the
#| {{DataName}} data."
{{DataName}}.pc |> plot()
#| label = "getLoadings"
{{DataName}}.pc$rotation |>
kable(caption="Principal Component Loadings for the {{DataName}} data.")
#| label = "biplot{{DataName}}.pc",
#| fig.cap = "Biplot for the {{DataName}} data."
{{DataName}}.pc |> biplot()
#| label = "augment{{DataName}}.pc"
{{DataName}}.pc.fit = {{DataName}}.pc |> augment({{DataName}})  
#| label = "scatter{{DataName}}.pc",
#| fig.cap = "Scatter plot of the first and second principle component
#| scores."
{{DataName}}.pc.fit |> ggplot(aes(x=.fittedPC1, y=.fittedPC2)) + 
  geom_point(size = 1.5) 


Try the BrailleR package in your browser

Any scripts or data that you put into this service are public.

BrailleR documentation built on July 26, 2023, 5:46 p.m.