R/varRequest.R

Defines functions varRequest

Documented in varRequest

#' Return the percentage of instances of a certain variable based on another.
#'
#' @param x a data frame.
#' @param y the column of the data frame to filter by.
#' @param b the variable being filtered by.
#' @param z the column of the data frame to search.
#' @param a the variable being tested.
#' @return A vector made up of percentage values of the instances of a certain variable. \code{y}.
#' @examples
#' varRequest(x, y, b, z, a)
#' @export
varRequest <- function(x, y, b, z, a){
  sub <- x[y == b,]
  sub2 <- sub[sub$z == a]
  percent <- nrow(sub2)/nrow(mtcars)
  percent <- percent * 100
  return(percent)
}
Jacob909/prdctr documentation built on Dec. 18, 2021, 12:29 a.m.