Intro

This R package was built in STAT545 at UBC, and is intended for teaching/learning purposes only

The main goal of this R package is to compute power and logarithmic transformations without having to use ^ or **

Functions

There are four functions in this package: + square: + input: value to be squared + output: squared value + cube: + input: value to be cubed + output: cubed value + box_cox_transform: + input: response to be transformed; transformation parameter + output: transfromed response + inverse_box_cox_transfrom: + input: transfromed response to be undone; transformation parameter + output: raw response

Example execution

library(powers)
square(2, plot_it=FALSE)
#>[1] 4
cube(3, plot_it=FALSE)
#>[1] 9

box_cox_transform(2, 0.5)
#>[1] 0.8284271
box_cox_transform(2, 0)
#>[1] 0.6931472

inverse_box_cox_transform(0.8284271, 0.5)
#>[1] 2
inverse_box_cox_transform(0.6931472, 0)
#>[1] 2

We can apply powers in lists of vectors too!

listy_list <- list(4,2,9,0.2,-0.8,-0.4)
sapply(listy_list, square)
#>[1] 16.00, 4.00, 81.00, 0.04, 0.64, 0.16

lapply(listy_list, box_cox_transform, t_param=0.5)
#> [[1]]
#[1] 2

#[[2]]
#[1] 0.8284271

#[[3]]
#[1] 4

#[[4]]
#[1] -1.105573

#[[5]]
#[1] "Number not real, check input"

#[[6]]
#[1] "Number not real, check input"

And That's All Folks



margotgunning/powers documentation built on May 29, 2019, 12:05 p.m.