-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Just wondering why lobstr::tree() doesn't show a breakdown of S4 class objects like str() does.
# create a dummy s4 class
setClass(
"Foo",
slots = c(
df = "data.frame",
ll = "list",
mat = "matrix"
)
)
# create a dummy s4 class object
foo <- new(
"Foo",
df = data.frame(
id = 1:3,
name = c("A", "B", "C"),
val = c(10.5, 20.2, 15.3),
stringsAsFactors = FALSE
),
ll = list(
group1 = list(a = 1, b = 2),
group2 = list(x = "hello", y = "world")
),
mat = matrix(1:6, nrow = 2, ncol = 3)
)
str(foo)
#> Formal class 'Foo' [package ".GlobalEnv"] with 3 slots
#> ..@ df :'data.frame': 3 obs. of 3 variables:
#> .. ..$ id : int [1:3] 1 2 3
#> .. ..$ name: chr [1:3] "A" "B" "C"
#> .. ..$ val : num [1:3] 10.5 20.2 15.3
#> ..@ ll :List of 2
#> .. ..$ group1:List of 2
#> .. .. ..$ a: num 1
#> .. .. ..$ b: num 2
#> .. ..$ group2:List of 2
#> .. .. ..$ x: chr "hello"
#> .. .. ..$ y: chr "world"
#> ..@ mat: int [1:2, 1:3] 1 2 3 4 5 6
library(lobstr)
tree(foo)
#> S4<Foo>Created on 2025-08-22 with reprex v2.1.1
Session info
sessionInfo()
#> R version 4.4.3 (2025-02-28)
#> Platform: aarch64-apple-darwin20.0.0
#> Running under: macOS Sequoia 15.6
#>
#> Matrix products: default
#> BLAS: /opt/homebrew/Caskroom/miniforge/envs/r-4.4-arm/lib/libblas.3.9.0.dylib
#> LAPACK: /opt/homebrew/Caskroom/miniforge/envs/r-4.4-arm/lib/liblapack.3.9.0.dylib
#>
#> locale:
#> [1] C
#>
#> time zone: Europe/Stockholm
#> tzcode source: system (macOS)
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] lobstr_1.1.2
#>
#> loaded via a namespace (and not attached):
#> [1] digest_0.6.37 fastmap_1.2.0 xfun_0.52 glue_1.8.0
#> [5] knitr_1.50 htmltools_0.5.8.1 rmarkdown_2.29 lifecycle_1.0.4
#> [9] cli_3.6.5 reprex_2.1.1 withr_3.0.2 compiler_4.4.3
#> [13] tools_4.4.3 evaluate_1.0.4 yaml_2.3.10 crayon_1.5.3
#> [17] rlang_1.1.6 fs_1.6.6Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels