Note: This package isn't actually meant to be "serious". This is a practice for STAT547M hw09.

This powers package makes it possible to calculate square, cube, the fourth power, and reciprocal and print out a corresponding scatter plot.

library(powers)

Want squares, cubes, the fourth powers, or reciprocal? Easy.

square(1:10)
cube(1:10)
reciprocal(5:10)

apply-family friendly, too!

my_list <- list(1:10, 0.5, -0.7)
## So base-R-boring!
lapply(my_list, function(x) x^2)
## Use powers instead!
lapply(my_list, square)

It has additional function to print out a scatter plot! The default value for the argument plot_it is FALSE.

reciprocal(1:10, plot_it = TRUE)
square(1:10, plot_it = TRUE)

In addition, it has an argument for na.omit. This is an option to remove NAs from an input vector. The default value is FALSE.

cube(c(1,2,3, NA, 5, 6, NA, 8), plot_it = FALSE, na.omit = TRUE)
four(c(1,2,3, NA, NA ,NA), na.omit = TRUE)

This powers package also has a boxcoxt function which print out the one-parameter Box-Cox transformation.
This function does not calculate the optimal lambda value. Using boxcox() in the MASS package is recommended for the optimal lambda. The default value of lambda is 0.1

boxcoxt(1:10, lambda = 0.3)

When the input lambda is too big(>5) or too small(<-5), there's a warning: "The input lambda value is too big or too small".

boxcoxt(1:10, lambda = 9)

For convenience, there are two datasets in powers package. Those datasets are 1:10, -(1:10)

tenvec
negtenvec


bcahn7/STAT547M-hw09-An-Byeongchan documentation built on May 20, 2019, 5:46 p.m.