sxp: Inspect an object

Description Usage Arguments Details See Also Examples

Description

sxp(x) is similar to .Internal(inspect(x)), recursing into the C data structures underlying any R object. The main difference is the output is a little more compact, it recurses fully, and avoids getting stuck in infinite loops by using a depth-first search. It also returns a list that you can compute with, and carefully uses colour to highlight the most important details.

Usage

1
sxp(x, expand = character(), max_depth = 5L)

Arguments

x

Object to inspect

expand

Optionally, expand components of the true that are usually suppressed. Use:

  • "character" to show underlying entries in the global string pool.

  • "environment" to show the underlying hashtables.

  • "altrep" to show the underlying data.

  • "call" to show the full AST (but ast() is usually superior)

  • "bytecode" to show generated bytecode.

max_depth

Maximum depth to recurse. Use max_depth = Inf (with care!) to recurse as deeply as possible. Skipped elements will be shown as ....'

Details

The name sxp comes from SEXP, the name of the C data structure that underlies all R objects.

See Also

Other object inspectors: ast, ref

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
x <- list(
  TRUE,
  1L,
  runif(100),
  "3"
)
sxp(x)

# Expand "character" to see underlying CHARSXP entries in the global
# string pool
x <- c("banana", "banana", "apple", "banana")
sxp(x)
sxp(x, expand = "character")

# Expand altrep to see underlying data
x <- 1:10
sxp(x)
sxp(x, expand = "altrep")

# Expand environmnets to see the underlying implementation details
e1 <- new.env(hash = FALSE, parent = emptyenv(), size = 3L)
e2 <- new.env(hash = TRUE, parent = emptyenv(), size = 3L)
e1$x <- e2$x <- 1:10

sxp(e1)
sxp(e1, expand = "environment")
sxp(e2, expand = "environment")

lobstr documentation built on July 3, 2019, 1:05 a.m.