module3.R

mycalc <- function(x, y, fun) {
  if(fun == "sum") {
    o <- sum(x, y)
  } else if(fun == "subtract") {
    o <- (x - y)
  } else if(fun == "multiply") {
    o <- (x * y)
  } else if(fun == "divide") {
    o <- (x / y)
  } else {
    o <- paste("Not a recognized function")
  }
  return(o)
}
BigBoat8542/Geog_analysis_R documentation built on Dec. 17, 2021, 10:50 a.m.