[Rd] Format printing inside a matrix

Abby Spurdle @purd|e@@ @end|ng |rom gm@||@com
Mon Jul 8 03:34:42 CEST 2019


> The problem of wrapping the list into a S3/S4 object, i.e. subclassing
array
> or matrix, is that one also has to define a bunch of methods for
subsetting,
> joining, etc, in order to make it behave like a list array.

False, sorry.
Wrapping != Defining a New Class.
And you don't have to define any methods.
However, my understanding of your original post is that you want to modify
the printing.
So, there would only need to be one method, a print method.

And if you don't want to do that, you could just create a stand alone
custom print function:
my.print.function = function (my.matrix.object, quote=FALSE, max.chars=10L)
{   do.something ()
}

> It is not desirable if a
> simple matrix subsetting will remove the class attributes of the object.

I'm assuming by "the object" you are referring to the matrix.
And by "class attribute"-"s" you are referring to all the attributes.
This is a completely separate discussion from your original post.
And I don't see what it has to do with printing matrices with a list type.

Note that subsetting only removes attributes from the matrix, it does not
remove attributes (or slots) from each object in the matrix.
Also, note that you may need to use "obj [[i, j]]", with *double* brackets.
Because
> attributes (obj [i, j])
Will be NULL.

	[[alternative HTML version deleted]]



More information about the R-devel mailing list