> From: Liaw, Andy > > > From: Paul Roebuck > > > > On Wed, 15 Sep 2004, Peter Dalgaard wrote: > > > > > Paul Roebuck <[EMAIL PROTECTED]> writes: > > > > > > > Is there a means to split a vector into its individual > > > > elements without going the brute-force route for arguments > > > > to a predefined function call? > > > > > > > > offred.rgb <- c(1, 0, 0) * 0.60; > > > > > > > > ## Brute force style > > > > offred.col <- rgb(offred.rgb[1], > > > > offred.rgb[2], > > > > offred.rgb[3], > > > > names = "offred") > > > > ## Desired style > > > > offred.col <- rgb(silver.bullet(offred.rgb), > > > > names = "offred") > > > > > > The closest is probably this: > > > > > > offred.col <- do.call("rgb", c(as.list(offred.rgb), > > > list(names="offred"))) > > > > Everyone offered 'do.call' as the solution. While that > > works, is it to say that there is no means of expanding > > the expression as an argument to the original function? > > What would be the point? That's what do.call() does for you > internally.
Is this what you're after? > toCall <- c(as.name("rgb"), as.list(offred.rgb), names="offred") > toCall [[1]] rgb [[2]] [1] 0.6 [[3]] [1] 0 [[4]] [1] 0 $names [1] "offred" > toCall <- as.call(toCall) > toCall rgb(0.6, 0, 0, names = "offred") > eval(toCall) [1] "#990000" Andy > Andy > > > > (ever read/seen The Handmaid's Tale, btw?) > > > > > > > Not yet. Though renaming my sample variable 'off.red.col' > > would avoid future confusion with oppressed handmaids. > > > > ---------------------------------------------------------- > > SIGSIG -- signature too long (core dumped) > > > > ______________________________________________ > > [EMAIL PROTECTED] mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > > > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > -------------------------------------------------------------- > ---------------- > Notice: This e-mail message, together with any attachments, > contains information of Merck & Co., Inc. (One Merck Drive, > Whitehouse Station, New Jersey, USA 08889), and/or its > affiliates (which may be known outside the United States as > Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as > Banyu) that may be confidential, proprietary copyrighted > and/or legally privileged. It is intended solely for the use > of the individual or entity named on this message. If you > are not the intended recipient, and have received this > message in error, please notify us immediately by reply > e-mail and then delete it from your system. > -------------------------------------------------------------- > ---------------- > ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html