Re: [Rd] rep fails on pairlist

2012-07-26 Thread Dirk Eddelbuettel

On 26 July 2012 at 15:55, 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?

FWIW there are changes happening right now to rep() so that may be spillage
from code under development.  To keep abreast of these changes, I follow the
RSS feed Duncan set up a few years ago -- it is also as html at

   http://developer.r-project.org/blosxom.cgi/R-devel

and summarizes changes committed to the NEWS file, ie high-level changes
worth knowing about.

Dirk

-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] rep fails on pairlist

2012-07-26 Thread Gabor Grothendieck
On Thu, Jul 26, 2012 at 4:24 PM, Dirk Eddelbuettel e...@debian.org wrote:

 On 26 July 2012 at 15:55, 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?

 FWIW there are changes happening right now to rep() so that may be spillage
 from code under development.  To keep abreast of these changes, I follow the
 RSS feed Duncan set up a few years ago -- it is also as html at

http://developer.r-project.org/blosxom.cgi/R-devel

 and summarizes changes committed to the NEWS file, ie high-level changes
 worth knowing about.

That page says:

Calling ‘rep()’ or ‘rep.int()’ on a pairlist or other non-vector
object is now an error.

so it again seems to be intentional.

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

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] rep fails on pairlist

2012-07-26 Thread Duncan Murdoch

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.


Duncan Murdoch

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] rep fails on pairlist

2012-07-26 Thread Gabor Grothendieck
On Thu, Jul 26, 2012 at 7:29 PM, Duncan Murdoch
murdoch.dun...@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

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel