Re: [R] promoting scalar arguments to vectors in a function

2016-05-23 Thread Marc Schwartz
On May 23, 2016, at 10:59 AM, jlu...@ria.buffalo.edu wrote: > > R users: > > Suppose I have a function that takes three numeric arguments x, y, and z, > any of which may be scalars or vectors. > Suppose further that the user takes one of the arguments, say y, as a > vector with the other two

Re: [R] promoting scalar arguments to vectors in a function

2016-05-23 Thread Jeff Newmiller
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.

Re: [R] promoting scalar arguments to vectors in a function

2016-05-23 Thread S Ellison
> -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > Suppose I have a function that takes three numeric arguments x, y, and z, any > of which may be scalars or vectors. > Suppose further that the user takes one of the arguments, say y, as a vector >

[R] promoting scalar arguments to vectors in a function

2016-05-23 Thread JLucke
R users: Suppose I have a function that takes three numeric arguments x, y, and z, any of which may be scalars or vectors. Suppose further that the user takes one of the arguments, say y, as a vector with the other two as scalars. Is there an existing R function that will promote the other