[R] ave(x, y, FUN=length) produces character output when x is character
Mike Miller
mbmiller+l at gmail.com
Thu Dec 25 22:19:27 CET 2014
On Thu, 25 Dec 2014, Duncan Murdoch wrote:
> On 25/12/2014 1:57 PM, Mike Miller wrote:
>
>> I do think I get what is going on with this, but why should I buy into
>> this conceptualization? Why is it better to say that a matrix *is* a
>> vector than to say that a matrix *contains* a vector? The latter seems
>> to be the more common way of thinking but such things.
>
> "More common"? The better way to think of this is as a class hierarchy.
> A matrix is a particular kind of vector (the kind that has a dimension
> attribute). A matrix has all the properties that a vector has, plus
> some more.
>
> Would you say a cube contains a polygon, or a cube is a polygon?
I would say that the sides of the cube are polygons, so I guess a cube
"contains" six polygons, but "is" would be wrong because a cube is a
polyhedron, not a polygon. A cube is not a polygon.
I get your point about hierarchy.
Someone else showed me that setting the dim attribute to NULL changes the
matrix into a vector so that is.vector() is TRUE.
Mike
More information about the R-help
mailing list