Skip to content

str() behaves strangely #42

@RobinHankin

Description

@RobinHankin

Following issue #40, str() behaves strangely:

suppressMessages(library("spray"))
a1 <- spray(matrix(c(0,2,1,2,2,2),ncol=2),c(1,1,-2))
a2 <- spray(matrix(c(2,1,1,1),ncol=2),c(-2,2))
a1
#>          val
#>  1 2  =   -2
#>  2 2  =    1
#>  0 2  =    1
a2
#>          val
#>  1 1  =    2
#>  2 1  =   -2
str(a1)
#> Class 'spray'  hidden list of 2
#>  $ index: int [1:3, 1:2] 1 2 0 2 2 2
#>  $ value: num [1:3] -2 1 1
str(a2)
#> List of 2
#>  $ index: int [1:2, 1:2] 1 2 1 1
#>  $ value: num [1:2] 2 -2
#>  - attr(*, "class")= chr "spray"

Created on 2023-07-03 with reprex v2.0.2

Above we see that sometimes str() returns a "Class 'spray' hidden list of 2" [as for a1] and sometimes returns a "List of 2" [as for a2] and it is not clear why.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions