Date: Mon, 24 Feb 1997 19:40:51 +1030 Message-Id: <9702240910.AA03385@attunga.stats.adelaide.edu.au> From: Bill Venables <wvenable@attunga.stats.adelaide.edu.au> To: Jim Lindsey <jlindsey@luc.ac.be> Subject: Re: R-alpha: Recycling In-Reply-To: <9702240738.AA12041@alpha.luc.ac.be> Jim Lindsey writes: > When I condemned recycling vectors, I did not mean to include > scalars as well. S (and R) does not have a separate scalar type. > y <- x+1 > should not create problems and should be allowed, as in GLIM. > y <- x+z > where x and z have different lengths, should be an error > instead of recycling the shorter one. Jim But this rule is exceptionally useful. For example consider a matrix product involving a diagonal matrix, say diag(d) %*% X. You can either do it that way or simply by (d * X) using the recycling rule. If X is 10000 x 7, say, so d is a vector of length 10000, which is quicker and uses less memory? There may be a case for disallowing the recycling rule when the longest length is not an exact multiple of all the shorter ones, (and this is part of S version 4, in fact), but if you outlaw all except "scalar" recycling you are really ditching a lot of power. Bill Venables. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- r-testers mailing list -- For info or help, send "info" or "help", To [un]subscribe, send "[un]subscribe" (in the "body", not the subject !) To: r-testers-request@stat.math.ethz.ch =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-