R/countOfsomething.2.R

Defines functions countOfsomething.2

Documented in countOfsomething.2

#' Function to count the number of some occurences in a vector
#'
#'
#' @param vec A character or boolean vector
#' @param something A character vector of lenght one specifying the strings or boolean we want to count
#' @author Alexander Kheirallah ([email protected])
#' @export
#' 
countOfsomething.2 <- function(vec,something) { 
  if(anyNA(vec)){
    print("Input vector to countOfsomething.2 has NA. Returning NA.")
    return(NA)
  }
  count_out <- 0
  for(i in 1:length(vec)){
    if(vec[i] == something){
      count_out <- count_out + 1
    }
  }
  return(count_out)
}
msxakk89/dat documentation built on March 25, 2020, 3:18 p.m.