Slightly more transparent but arguably uglier:

> offred.rgb <- c(1, 0, 0) * 0.60
> ofr <- paste(offred.rgb, collapse=",")
> ofr. <- paste("rgb(", ofr, ',names="offred")')
> ofr.
[1] "rgb( 0.6,0,0 ,names=\"offred\")"
> eval(parse(text=ofr.))
offred
"#990000"
>
As long as I can remember "eval(parse(text=", this is for me the most transparent and works for constructing virtually any R command.


     hope this helps.  spencer graves

Peter Dalgaard wrote:

Paul Roebuck <[EMAIL PROTECTED]> writes:



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?



Not really. You need an explicit expansion of the argument to a list somehow, and there's no silver bullet that can convert one function argument to several. There are solutions without do.call, like



offred.rgb <- c(1, 0, 0) * 0.60
x <- quote(rgb(.,.,.,names="offred"))
x[2:4] <- as.list(offred.rgb)
eval(x)


  offred
"#990000"

but you might find it difficult to explain how it works a year later....





-- Spencer Graves, PhD, Senior Development Engineer O: (408)938-4420; mobile: (408)655-4567

______________________________________________
[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

Reply via email to