From ggrothendieck at gmail.com  Fri Jul 27 01:31:52 2012
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Thu, 26 Jul 2012 19:31:52 -0400
Subject: [Rd] rep fails on pairlist
In-Reply-To: <5011D2CF.3030001@gmail.com>
References: <CAP01uRkj9jBY0=G=kL3UjHMhhfNvn35=483qqxV_3XcZeEUVkQ@mail.gmail.com>
	<5011D2CF.3030001@gmail.com>
Message-ID: <CAP01uRm10L4Tds6d7JR3cTjAF0O0WZ7vrxEj+KH=doibBdGqFw@mail.gmail.com>

On Thu, Jul 26, 2012 at 7:29 PM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
> On 12-07-26 3:55 PM, Gabor Grothendieck wrote:
>>
>> This code which has worked for years in R but fails under R-devel:
>>
>>> R.version.string
>>
>> [1] "R Under development (unstable) (2012-07-25 r59963)"
>>>
>>>
>>> n <- 3
>>> f <- function(x) {}
>>> formals(f) <- rep(formals(f), n) ##
>>
>> Error in rep(formals(f), n) : replication of pairlists is defunct
>>
>> The message suggests that the change was intentional.
>> Why was this functionality removed?
>> What code should be used in its place?
>>
>>
>
> rep() on a pairlist didn't return a pairlist, it coerced to a list and then
> rep'd that.  So you could do the same explicitly if that's what you really
> want:
>
> formals(f) <- rep(as.list(formals(f)), n)
>
> This works because the formals<- code is forgiving; other uses of pairlists
> would not accept the result of rep on a pairlist.
>

Thanks. I will use that instead.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



[Rd] rep fails on pairlist
Gabor Grothendieck