Skip to content
Prev 361109 / 398506 Next

promoting scalar arguments to vectors in a function

Scalar values in R are just vectors of length 1. The "promotion" you are thinking of is "recycling" that automatically occurs when vectors of different lengths are supplied to certain operations. 

One shortcut might be to put them all into a data frame using the data.frame() function.  Otherwise, I think the rep() function and some conditional code would be needed.