Displaying 1 result from an estimated 1 matches for "altnrow".
Did you mean:
alteroo
2010 Jul 25
0
Redefine NROW and NCOL to be compatible with nrow and ncol for S3 classes with own dim function?
...im attribute. It is defined as follows
in the base package:
function (x) {
if (is.array(x) || is.data.frame(x)) nrow(x) else length(x)
}
<environment: namespace:base>
In my opinion, a good solution would be the following alternative
specification:
# Alternative definition of NROW
ALTNROW = function(x) {
d = dim(x)
if (!is.null(d)) d[1] else length(x)
}
Here a check that it works for the Custom Class MatrixRef, as well as, a
selection of alternative standard classes:
> vec = runif(10)
> mat = matrix(1:8,4,2)
> df = data.frame(mat)
> li = list("a",...