Dropping all names in a printed array



next up previous contents
Next: Recursive numerical integration Up: More advanced examples Previous: Efficiency factors in

Dropping all names in a printed array

For printing purposes with large matrices or arrays, it is often useful to print them in close block form without the array names or numbers. Removing the dimnames attribute will not achieve this effect, but rather the array must be given a dimnames attribute consisting of empty strings. For example to print a matrix, X

temp <- X

dimnames(temp) <- list(rep("", nrow(X)), rep("", ncol(X))

temp; rm(temp)

This can be much more conveniently done using a function, no.dimnames(), shown in Figure 6, as a ``wrap around'' to achieve the same result. It also illustrates how some effective and useful user functions can be quite short.

 
Figure 6:   A function for printing arrays in compact form

With this function defined, an array may be printed in close format using

no.dimnames(X)

This is particularly useful for large integer arrays, where patterns are the real interest rather than the values.



Erik Moledor
Tue Jan 31 21:02:18 EST 1995