From Martin Maechler <maechler@stat.math.ethz.ch>  Tue May 20 17:24:48 1997
From: Martin Maechler <maechler@stat.math.ethz.ch> (Martin Maechler)
Date: Tue, 20 May 97 18:24:48 +0200
Subject: R-alpha: rep(.) and aperm(.)  lose names(.) and dimnames(.)  -- Patch
Message-ID: <9705201624.AA00517@>

The following patches fix the problem.
For aperm, it's quite important to keep dimnames(.);
for rep(.), it's arguable, however S(-plus) does it...

However, it would probably be better to this in the '.Internal' code for
all attributes.

Patch to be applied in		$RHOME/src/library/base/funs/ 

--- rep~	Sun Nov 24 23:42:29 1996
+++ rep		Tue May 20 18:20:12 1997
@@ -5,6 +5,7 @@
 	if (missing(times))
 		times <- ceiling(length.out/length(x))
 	r<-.Internal(rep(x,times))
+	if(!is.null(nm <- names(x))) names(r) <- .Internal(rep(nm, times))
 	if (!missing(length.out))
 		return(r[1:length.out])
 	return(r)

--- aperm~	Sun Nov 24 23:42:20 1996
+++ aperm	Tue May 20 18:20:10 1997
@@ -7,5 +7,7 @@
 		if(!all(sort(perm)==1:length(perm)))
 			stop("perm is not a permutation")
 	}
-	.Internal(aperm(a,perm,resize))
+	r <- .Internal(aperm(a, perm, resize))
+	if(!is.null(dn <- dimnames(a))) dimnames(r) <- dn[perm]
+	r
 }

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


R-alpha: rep(.) and aperm(.) lose names(.) and dimnames(.) -- Patch
Martin Maechler