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. 
-- 
Sent from my phone. Please excuse my brevity.

On May 23, 2016 8:59:55 AM PDT, 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 as scalars.
>Is there an existing R function that will promote the other two
>arguments 
>to vectors of the same size?
>
>I know in most cases this is not a problem as the promotion is
>automatic. 
>I need this for a function I am writing
>and I don't want to write any additional code to do this if I can help
>it.
>
>Joe
>Joseph F. Lucke, PhD
>Senior Statistician
>Research Institute on Addictions
>University at Buffalo
>State University of New York
>1021 Main Street
>Buffalo, NY  14203-1016
>
>
>
>       [[alternative HTML version deleted]]
>
>______________________________________________
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to