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

Create a spread_array function #94

Open
jeremystan opened this issue Sep 19, 2016 · 1 comment
Open

Create a spread_array function #94

jeremystan opened this issue Sep 19, 2016 · 1 comment

Comments

@jeremystan
Copy link
Collaborator

From Hadley:

You definitely also need a spread_array() to complement
gather_array(). It's a rarer operation but still useful.

JSON arrays don't have names, so perhaps this would work like:

'[1, 2, 3]' %>% spread_array_int()
# A tbl_json: 1 x 3 tibble with a "JSON" attribute
  `attr(., "JSON")` document.id value.1 value.2 value.3
              <chr>       <int>   <int>   <int>   <int>
1         [1, 2, 3]           1       1       2       3
@colearendt
Copy link
Owner

Maybe add a selection of index, as well... A common problem is when an array has only one item, or you only care about the first / last item, etc. It is tedious to gather, filter, and then spread the array, not to mention joining back to the original data, when all that is really needed is a spread.

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

2 participants