dim has a method for data.frames, which returns
the lengths of the row.names attribute of x and
of x (as the numbers of rows and columns respectively).

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
The New S Language.
Wadsworth & Brooks/Cole.

# NOT RUN {x <- 1:12 ; dim(x) <- c(3,4)
x
# simple versions of nrow and ncol could be defined as followsnrow0 <- function(x) dim(x)[1]
ncol0 <- function(x) dim(x)[2]
# }