-
Notifications
You must be signed in to change notification settings - Fork 271
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
revisit: transpose() doesn't work as expected when inner keys are disjoint #318
Comments
Have a look at the new |
OK great! The lists I'm dealing with are large and I don't know in advance how all the children are named. So I would have to pre-map Here's how I am doing this task by hand right now (not a reprex, sorry ... just copy/paste). I make some effort to get a decent global order for the names: ## determine the names of sub-items and a consensus order
## get vector of names for each endpoint
nms_list <- endpoints %>%
map(names)
## union of names across endpoints
nms_glop <- nms_list %>%
reduce(union)
## reach a consensus on name order
nms_rksum <- nms_list %>%
map_dfc(~ match(nms_glop, .x)) %>%
rowSums(na.rm = TRUE)
nms <- nms_glop[order(nms_rksum)] |
What's the principle behind the global order? |
It's the order most consistent with how the names appear in the children of the input list, based on rank sum. If they always appear in same order, it will be that. In my current example, there is variation across the children in which names appear at all and in their order. A simpler approach would be to just take the unique values from the union of the names. I had to reorder mine manually anyway, so maybe it's not worth trying to be clever. |
Yeah, I'd think |
If it's not destined to be the default, then yes I think that would be great. Do you want me to do in a PR? |
Yes please! |
Deliberately repeating name of #205. I'm not sure #205 really was a duplicate of #164.
transpose()
seems to work just fine with names, so this is not about position. But it only seems to consult the first object to determine inner keys.The text was updated successfully, but these errors were encountered: