Show internal structure of an R object
data-structures, r, serialization
Solution
I don't have much more to add besides my comment, so this is just for completeness for future generations :)
`dput` is doing what you want. With rare exceptions, one of them being `pairlist` (I assume there might be other exceptions as well, but I don't actually know what they are), it will not be exactly the same object, but, at least in the case of `pairlist` there is a reason for that. Since `pairlist` is not supposed to be used outside of internal code, the output of `dput` can be considered to be doing the user a favor by converting an internal object into the equivalent external one.
Problem
Is there a way to show the complete internal structure of an R object in an unambiguous and human readable way? The `str` function doesn't exactly do this, as it shows custom representations. For example, applying it to an igraph object gives something like ``` IGRAPH U--- 3 3 -- Full graph + attr: name (g/c), loops (g/x) + edges: [1] 1--2 1--3 2--3 ``` This is nice and readable, but it's specific to igraph objects (it's clear that it uses a custom formatting for them). I'm looking for something general. I found `dput`, and for a while I thought that this provides complete information. The same igraph object is shown as ``` structure(list(3, FALSE, c(1, 2, 2), c(0, 0, 1), c(0, 1, 2), c(0, 1, 2), c(0, 0, 1, 3), c(0, 2, 3, 3), list(c(1, 0, 1), structure(list(name = "Full graph", loops = FALSE), .Names = c("name", "loops")), list(), list())), class = "igraph") ``` But then I read about pairlists in the R Language Definition and I noticed that `dput(pairlist(1,2))` gives `list(1,2)`. The information that we started with a pairlist is gone. So is there something similar to `dput` that shows the internal structure of an R object and gives complete information about it? (The main reason I want this is that it would help me understand the structure of R objects better.) If there isn't, how would I query an R object to get enough information about it (in a human readable way---not machine readable) to be able to reconstruct it completely?