Re: [R] list() assigning the same value to two items

From: Gabor Grothendieck <>
Date: Mon, 21 Jun 2010 12:33:09 -0400

On Mon, Jun 21, 2010 at 6:58 AM, Thaler, Thorn, LAUSANNE, Applied Mathematics <> wrote:
> Thanks, works as expected. But maybe I've to be a bit more clear about the reason why I'd like to have such a construct.
> In lattice you can define some parameters by passing a named list to par.settings. Suppose I want to superpose two lines and use colors different from the default:
> xyplot(1:10~c(1:5,1:5), type="o", groups=rep(1:2,each=5), par.settings=list(superpose.line=list(col=1:2), superpose.symbol=list(col=1:2)))
> I have to specify the same setting for superpose.line and superpose.symbol. If I'd use your proposition, I've to hardcode the respective item names. It is still an academic question, for there are thousands of ways to solve this issue, but I was just curious whether it is possible to find an one-liner without the need of specifying any temp variable.

Try this variation of my.transform that I had posted here:

List <- function(..., L = list()) {

       f <- function(){}
       formals(f) <- eval(substitute(as.pairlist(c(alist(...), L))))
       body(f) <- substitute(modifyList(L, list(...)))


xyplot(1:10~c(1:5,1:5), type = "o", groups = rep(1:2,each=5),  par.settings = List(
   superpose.line = list(col = 1:2),
   superpose.symbol = superpose.line)) mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Mon 21 Jun 2010 - 16:36:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 Jun 2010 - 07:20:33 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive