From radford at cs.toronto.edu  Wed Mar 26 18:24:19 2014
From: radford at cs.toronto.edu (Radford Neal)
Date: Wed, 26 Mar 2014 13:24:19 -0400
Subject: [Rd] R-devel Digest, Vol 133, Issue 23
In-Reply-To: <mailman.15.1395658807.28229.r-devel@r-project.org>
References: <mailman.15.1395658807.28229.r-devel@r-project.org>
Message-ID: <20140326172419.GA20735@cs.toronto.edu>

> From: Richard Cotton <richierocks at gmail.com>
> 
> The rep function is very versatile, but that versatility comes at a
> cost: it takes a bit of effort to learn (and remember) its syntax.
> This is a problem, since rep is one of the first functions many
> beginners will come across.  Of the three main uses of rep, two have
> simpler alternatives.
> 
> rep(x, times = ) has rep.int
> rep(x, length.out  = ) has rep_len
> 
> I think that a rep_each function would be a worthy addition for the
> third use case
> 
> rep(x, each = )
> 
> (It might also be worth having rep_times as a synonym for rep.int.)

I think this is exactly the wrong approach.  Indeed, the aim should be
to get rid of functions like rep.int (or at least discourage their
use, even if they have to be kept for compatibility).

Why is rep_each(x,n) better than rep(x,each=n)?  There is no saving in
typing (which would be trivial anyway).  There *ought* to be no
significant difference in speed (though that seems to have been the
motive for rep.int).  Are you trying to let students learn R without
ever learning about specifying arguments by name?

And where would you stop?  How about seq_by(a,b,s) rather than having
to arduously type seq(a,b,by=s)?  Maybe we should have glm_binomial,
glm_poisson, etc. so we don't have to remember the "family" argument?
This way lies madness...

   Radford Neal



[Rd] R-devel Digest, Vol 133, Issue 23
Radford Neal