I don\'t understand why the class of a vector is the class of the elements of the vector and not vector itself.
vector <- c(\"la\", \"la\", \"la\")
class
Here's the best diagram I've found that lays out the class hierarchy used by the class
function:
Although the class names don't correspond exactly with the results of the R class
function, I believe the hierarchy is basically accurate. The key to your answer is that the class
function only gives the root class in the hierarchy.
You will see that Vector
is not a root class. The root class for your example would be StrVector
, which corresponds to the "character"
class, the class for a vector with character elements. In contrast, Matrix
is itself a root class; hence, its class is "matrix"
.