From Martin Maechler <maechler@stat.math.ethz.ch>  Mon Nov  9 16:33:02 1998
From: Martin Maechler <maechler@stat.math.ethz.ch> (Martin Maechler)
Date: Mon, 9 Nov 1998 17:33:02 +0100
Subject: Proposal for discussion:  COLNAMES & ROWNAMES
In-Reply-To: <98Nov9.112254est.13464@mailgate.bank-banque-canada.ca> (message
 from Paul Gilbert on Mon, 9 Nov 1998 11:14:21 -0500)
References: <199811091434.PAA11456@sophie.ethz.ch> <98Nov9.112254est.13464@mailgate.bank-banque-canada.ca>
Message-ID: <199811091633.RAA17985@sophie.ethz.ch>

>>>>> "PaulG" == Paul Gilbert <pgilbert@bank-banque-canada.ca> writes:

    MM> COLNAMES <- function(x)
    MM>      if(is.null(n <- colnames(x))) paste(seq(length=NCOL(x))) else n
    MM> ROWNAMES <- function(x)
    MM>      if(is.null(n <- rownames(x))) paste(seq(length=NCOL(x))) else n

    MM> Do you have any positive or negative thoughts on this?

    PaulG> Here are a few thoughts.

thank you!

    PaulG> 0/ In ROWNAMES use NROW

oh yes !

    PaulG> 1/ You might try do this in some way that generalizes more
    PaulG> easily to arrays, but I'm not sure how.

this would mean DIMNAMES, presumably.

    PaulG> 2/ You might want paste("col", seq(length=NCOL(x))) instead of
    PaulG> just the numbers.

Not directly;
    In the places I've seen a possible use, 
    sometimes there was "var", sometimes "..." (forgotten), sometimes no
    prefix at all.  

However, we could add an optional argument `prefix', 
even with sensible defaults: 

    COLNAMES <- function(x, prefix = "col")
	if(is.null(n <- colnames(x)))
		paste(prefix, seq(length=NCOL(x)), sep="") else n
    ROWNAMES <- function(x, prefix = "row")
	if(is.null(n <- rownames(x)))
		paste(prefix, seq(length=NROW(x)), sep="") else n
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


Proposal for discussion: COLNAMES & ROWNAMES
Martin Maechler