From Kurt.Hornik@ci.tuwien.ac.at  Mon Jul 28 14:23:47 1997
From: Kurt.Hornik@ci.tuwien.ac.at (Kurt Hornik)
Date: Mon, 28 Jul 1997 15:23:47 +0200
Subject: R-alpha: new functions
Message-ID: <199707281323.PAA18631@aragorn.ci.tuwien.ac.at>

The following two functions might be worth adding to the distribution:

**************************************************************
as.ordered <- function(x) { 
  if (is.ordered(x)) x else ordered(x)
}

data.class <- function(x) {
  if (length(cl <- class(x)))
    cl[1]
  else {
    l <- length(dim(x))
    if (l == 2)
      "matrix"
    else if (l > 0)
      "array"
    else
      mode(x)
  }
}
**************************************************************

Re data.class:  Couldn't we introduce a "matrix" and an "array" class
right away?  (I already asked this once).  The functions for creating or
coercing such objects could easily add the corresponding class
attribute ...

-k
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
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: new functions
Kurt Hornik