Skip to content
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

When keep = any, keep rows that are completely null and assign them NA in all cols #66

Open
aedobbyn opened this issue May 24, 2018 · 0 comments

Comments

@aedobbyn
Copy link
Collaborator

aedobbyn commented May 24, 2018

Maybe this requires another argument like keep_all_rows.

In the example below, I think we should allow the user some way to end up with 4 rows instead of 3. The third row corresponding to baz should be all NAs.

It would be useful in cases I can imagine for the user to know that they got 4 distinct outputs back and that one of them was fully null.

library(magrittr)

some_json <- '
{
  "foo": [{
    "a": 1,
    "b": 2,
    "c": 3
  }],
  "bar":[{
    "a": 4,
    "b": null,
    "c": 6
  }],
  "baz": [],
  "bing":[{
    "c": 12
  }]
}
'

lst <- some_json %>% jsonlite::fromJSON()

lst %>% roomba::roomba(cols = c("a", "b", "c"), keep = any)
#>    a b c
#> 1  1 2 3
#> 2  4 NA 6
#> 3  NA NA 12

So what I think this should look like is:

#>    a  b  c
#> 1  1  2  3
#> 2  4  NA 6
#> 3  NA NA NA
#> 4  NA NA 12

Mostly useful when the user knows they're passing x number inputs to an API and expecting x outputs, even if some of those outputs are empty.

@bfgray3 bfgray3 mentioned this issue Jan 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant