I have a data.frame with columns \"a\" and \"b\". I want to add columns called \"high\" and \"low\" that contain the highest and the lowest among columns a and
data.frame
If your data.frame name is dat.
dat$pmin <- do.call(pmin,dat[c("a","b")]) dat$pmax <- do.call(pmax,dat[c("a","b")])