R/fbind.R

#load devtools package
library(devtools)

#two factors
(a <- factor(c("character", "hits", "your", "eyeballs")))
(b <- factor(c("but", "integer", "where it", "counts")))

#defining the fbind function

#' Bind two factors together
#'
#' Creating a new factor from two existing factors, where the new factor's levels
#' are the union of the levels of the input factors.
#'
#' @param a factor
#' @param b factor
#'
#' @return factor
#' @export
#' @examples
#' fbind(iris$Species[c(1,51,101)], PlantGrowth$group[c(1,11,21)])
fbind <- function(a,b) {
  factor(c(as.character(a), as.character(b)))
}

#mini test for the fbind function
fbind(a,b)
namanpaul/hw08 documentation built on May 23, 2019, 12:17 p.m.