The goal of powers is to serve as the homework of STAT547M.
This package include following functions, - squre(): take the square of a vector; - boxcox(): take the boxcox transformations of a vector, - boxcox.inv(): take the inverse boxcox transformations of a vector, - na.filter(): filter out NA values by row or columns specified by the user for a dataset
``` {r, warning = FALSE} devtools::install_github("zxkathy/powers") library(powers)
## Quick Guide ####1. Function of `square()` ```r square(4) square(c(1:3)) square(TRUE)
As we expected, the square function works well in the vector or number forms. Let's try another one.
square("x") m <- data.frame(cbind(c(1,2), c(3,4))) class(m) square(m)
The square function only works in forms of vector of numeric, so it won't work for both str "x"
and data.frame m
.
The unit test file of square()
is here, and all the test passed.
boxcox()
and boxcox.inc()
boxcox(2, lambda = 3) boxcox(1:3, lambda = 0)
boxcox.inv(2, lambda = 3) boxcox.inv(1:3, lambda = 0)
The above boxcox()
formula was obtained from the link. It doesn't specify the range of lambda
and x
, so when I get the case of boxcox result is 0, its inverse should be Inf
.
Additionally, the above boxcox.inv()
relies on the function of boxcox()
. It basically just takes the inverse of the result of boxcox()
.
boxcox(-1, 0)
As log(.) does not work for negative numbers, so I added a error point when the user's input of x
is negative.
The unit test file of boxcox()
and boxcox.inv()
is here, and all the test passed.
filter.na()
This function has two output, first one indicating whether the dataset contains any NA values, second one indicating the NA filtered dataset. User can specify how to remove the NA values, either by column or by row, as specified by the user.
a <- data.frame(cbind(c(1,2), c(NA, 3), c("m",7))) class(a) filter.na(a, direction = "row")
b <- data.frame(cbind(c(1,2), c(5, "kk"), c(5,7))) class(b) filter.na(b, direction = "col")
c <- cbind(c(1,2), c(NA, 7), c(5,7)) class(c) filter.na(c, direction = "col")
The unit test file of filter.na()
is here, and all the test passed.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.