Closed tylerlittlefield closed 4 years ago
What do you have in mind for a fix? Can I just add as.data.frame()
to build_tree()
? lol
We could, but usually when tibble
fails, it's because we're doing something we shouldn't, tibble
is more strict than data.frame
:
So we will probably want to find out where this is coming from and resolve. I just haven't taken a look yet.
I found the culprit:
This is essentially what is happening in parse root:
parse_root <- function(x, settings) {
list(
id = x[x[[settings$link]] %in% settings$root_tag, settings$child_id],
dat = x[x[[settings$link]] %in% settings$root_tag, ]
)
}
The integrity of a tibble structure is maintained when you subset a single value using base R syntax. In the example above, root$id is a tibble, when the expectation of root is a character/string. I suppose it makes sense that tibble maintains the structure when subsetting but I don't love it cuz it conflicts with how base R dataframes behave, but it will not kill me to wrap x[x[[settings$link]] %in% settings$root_tag, settings$child_id]
in as.character()
.
What do you think?
Oh yeah, I always forget about drop
, i.e. iris[1, "Sepal.Width", drop = FALSE]
. I think as.character
works (unless we want to preserve type), in which case you could use [[
:
df <- iris
df_tbl <- tibble::as_tibble(iris)
df[[1, "Sepal.Length"]]
df_tbl[[1, "Sepal.Length"]]
more square brackets............ 😖
Your call, I don't think the type matters... so as.character
works.
Closed #23
It works regular
data.frame
so we need to figure out how to get it to work withtibble
: