R/hello.R

Defines functions calcu_pca_var hello

Documented in hello

# Hello, world!
#
# This is an example function named 'hello' 
# which prints 'Hello, world!'.
#
# You can learn more about package authoring with RStudio at:
#
#   http://r-pkgs.had.co.nz/
#
# Some useful keyboard shortcuts for package authoring:
#
#   Install Package:           'Cmd + Shift + B'
#   Check Package:             'Cmd + Shift + E'
#   Test Package:              'Cmd + Shift + T'

hello <- function() {
  print("Hello, world!")
}


calcu_pca_var = function(pca_obj){
  eigs = (pca_obj$sdev)^2
  rbind(
    SD = sqrt(eigs),
    Proportion = eigs/sum(eigs),
    Cumulative = cumsum(eigs)/sum(eigs)) 
}
shudengnyc/shutool documentation built on Jan. 9, 2023, 10:40 p.m.