Introduction

This is a practice package for STAT545 course. The foofactors package has a three cool functions to make working with factors easier and fun. Look at the "Usage" section below or the vignette for examples.

Installation:

install_github("KPdir/foofactors")

Load in R:

library(foofactors)

Usage

Exmaple use of fbind

iris$Species[c(1, 51, 101)]
PlantGrowth$group[c(1, 11, 21)]
# Bind these factors together
fbind(iris$Species[c(1, 51, 101)], PlantGrowth$group[c(1, 11, 21)])

Exmaple use of freq_out

str(iris)
# Tabulate the number of entries of each kind of species
freq_out(iris$Species)

Exmaple use of splitlevel

# Example 1
x <- data.frame(first = c(1:6), second = rep(c("A","B"), each = 3), third = rep_len(c("W","X","Y","Z"), 6))
# Split the level "A" in the "second" column oof the data frame based on the "third" column
splitlevel(x,"second","A","third", "callitwhatyouwant")
# Example 2
iris2 <- iris
brks<- suppressWarnings(quantile(iris$Sepal.Length, na.rm = TRUE)
                                - c(1e-05, 0, 0, 0))
# Add a factor level just so we can test our function
iris2["Quantile"] <- cut(iris$Sepal.Length ,breaks = brks,
                             labels = c("Q1", "Q2", "Q3", "Q4"))
# Show limited columns
# Display top 20 items 
head(iris2[c("Sepal.Length", "Species","Quantile")],20)
# Display bottom 20 items
tail(iris2[c("Sepal.Length", "Species","Quantile")],20)
# Split the level "virginica"" based on the factor "Quantile" and call the 
# new factor level "MySplitLevel"
iris2 <- splitlevel(iris2,"Species","virginica","Quantile", "MySplitLevel")
# Display top 20 items 
head(iris2[c("Sepal.Length", "Species","Quantile", "MySplitLevel")],20)
# Display bottom 20 items
tail(iris2[c("Sepal.Length", "Species","Quantile", "MySplitLevel")],20)


KPdir/foofactors documentation built on May 8, 2019, 4:41 p.m.