search for: vector_or_factor

Displaying 4 results from an estimated 4 matches for "vector_or_factor".

2018 May 16
2
Dispatch mechanism seems to alter object before calling method on it
...# [1] "integer" is.vector(matrix()) # [1] FALSE is(matrix(), "vector") # [1] TRUE is.list(data.frame()) # [1] TRUE is(data.frame(), "list") # [1] FALSE extends("data.frame", "list") # [1] TRUE setClassUnion("vector_OR_factor", c("vector", "factor")) is(data.frame(), "vector") # [1] FALSE is(data.frame(), "factor") # [1] FALSE is(data.frame(), "vector_OR_factor") # [1] TRUE etc... Many people stay away from S4 because of these incomprehensible...
2018 May 16
2
Dispatch mechanism seems to alter object before calling method on it
On 05/15/2018 09:13 PM, Michael Lawrence wrote: > My understanding is that array (or any other structure) does not > "simply" inherit from vector, because structures are not vectors in > the strictest sense. Basically, once a vector gains attributes, it is > a structure, not a vector. The methods package accommodates this by > defining an "is" relationship
2018 May 16
1
Dispatch mechanism seems to alter object before calling method on it
..."list") won't need to compromise anymore and will be free to return the correct answer. > >> >> is(data.frame(), "vector") >> # [1] FALSE >> is(data.frame(), "factor") >> # [1] FALSE >> is(data.frame(), "vector_OR_factor") >> # [1] TRUE >> > > The question is: which inheritance to follow, S3 or S4? Since "vector" > is a basic class, inheritance follows S3 rules. But the class union is > an S4 class, so it follows S4 rules. > >> etc... >> >> Many pe...
2018 May 16
0
Dispatch mechanism seems to alter object before calling method on it
...") > # [1] TRUE > This is a compromise for compatibility with inherits(), since the result of data.frame() is an S3 object. > > is(data.frame(), "vector") > # [1] FALSE > is(data.frame(), "factor") > # [1] FALSE > is(data.frame(), "vector_OR_factor") > # [1] TRUE > The question is: which inheritance to follow, S3 or S4? Since "vector" is a basic class, inheritance follows S3 rules. But the class union is an S4 class, so it follows S4 rules. > etc... > > Many people stay away from S4 because of these incompr...