R/sum_product.r

#' Sum Product
#'
#' @param x : a numeric vector.
#' @param y : a numeric vector.
#'
#' @return a numeric vector of length 1
#' @export
#'
#' @examples
#' sum_product(1:5,6:10)
sum_product <- function(x,y){
  if(length(x)!=length(y)){
    stop("Length of x and y must be the same.")
  }else if(length(x)<1){
    stop("Length of x and y must be greater than 0.")
  }else if(!(is.numeric(x)==T & is.numeric(y)==T)){
    stop("x and y must be numeric.")
  }else{
    return(sum(x*y))
  }

}
ArithmeticR/TOmisc documentation built on May 14, 2019, 12:43 p.m.