-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A better str for simple objects #2
Comments
Possible short name:
Really nice!
It would be cool to have a more flexible control of the levels to display than info(deep, 3) # 3 first levels
info(deep, -3) # 3 last levels
info(deep, c(5, 10)) # levels in the range [5, 10]
Right, it really depends what the user is looking for. Maybe reduce the amount of information displayed as we go down the hierarchy? Then we can use the level argument to get more complete info about deeper levels. #> list[1]
#> 1. list[1]
#> 1. list[1]
#> 1. list[1]
#> 1. list ...(5-96) # Some kind of hint about remaining depth?
Maybe treat first level objects specially. So |
Ideas for displaying functions:
l <- list(data, write.table, list)
str(l)
#> List of 3
#> $ :function (..., list = character(), package = NULL, lib.loc = NULL, verbose = getOption("verbose"),
#> envir = .GlobalEnv)
#> $ :function (x, file = "", append = FALSE, quote = TRUE, sep = " ", eol = "\n",
#> na = "NA", dec = ".", row.names = TRUE, col.names = TRUE, qmethod = c("escape",
#> "double"), fileEncoding = "")
#> $ :function (...)
#> ..- attr(*, "class")= chr [1:2] "namespace" "roclet"
info(l)
#> list[3]
#> - 1: function[utils]
#> @args: ..., list, package, lib.loc, ....
#> - 2: function[utils]
#> @args: file, append, quote, sep, eol, ....
#> - 3: function[base] <namespace, roclet>
#> @args: ... |
Long live
This rings very true. If you knew that the list had repeated structure, then you want to see detail on one element, presumably the first, and then just a note that there are 99 more things of a similar nature. But that ties back to the separate problem of detecting repeated structure. Maybe it would be good to record when you know a list has repeated structure by its very construction (i.e. df %>% group_by() %>% nest() ?%>% mutate()? or lst %>% map()). You get those for free! These sorts of lists remind me of short tandem repeats in a genome. |
@jennybc I think that circles back to the purrr issue. I think we need a "homogenous" list class that just asserts that all the elements of the list are of the same type. @lionel- what do you imagine looking at the last 3 levels in a list would look like? For a bit more context, I'm imaging that in the near future (< 12 months) RStudio will gain an interactive widget that lets you drill down iteratively into a deeply nested list. So this function doesn't need to solve every deeply nested navigation problem, it just needs to give a decent textual output. |
The function would figure out the depth of each branch, and only show the branches deep enough: l <-
list(
list(
list(
list(
4
),
list(
list(
5
)
)
)
),
list(
2
)
)
info(l, -3)
#> ---levels 3 to 5---
#> list[2]
#> - 1: list[1]
#> - 1: dbl[1]
#> - 2: list[1]
#> - 1: list[1]
#> - 1: dbl[1] |
Challenging list from @jennybc at https://gist.github.com/jennybc/12d75a88edf37cc996eb |
Another good example list: |
Two recent ideas:
|
Also need to think this through post-BigQuery insights - is a list-col an array or a record or a repeated record? I think we could have a method to impute the "type" of a list column, and then display arrays, records, and repeated records in different ways. |
This is particularly important for list-columns since there's no good way to see them currently. |
Here's a screenshot of the printing of a nested list structure, from something I'm working on. Some of the ideas may be useful here: Some notes about it:
|
Starting to noodle on this idea because I think it will be useful for the data structures chapter in R4DS
cc @jennybc, @lionel-
The text was updated successfully, but these errors were encountered: