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 collapse_table, expand_table functions #37

Open
jorainer opened this issue Dec 4, 2018 · 3 comments
Open

Create collapse_table, expand_table functions #37

jorainer opened this issue Dec 4, 2018 · 3 comments

Comments

@jorainer
Copy link
Member

jorainer commented Dec 4, 2018

Create functions that allow to collapse or expand a data.frame keeping unique values in some columns and list of elements in the other.

@jorainer
Copy link
Member Author

jorainer commented Dec 6, 2018

Collapsing a data.frame turns out to be quite simple, but expanding it is tricky.

jorainer added a commit that referenced this issue Dec 6, 2018
- Add .column_indices and .collapse_table function (issue #37).
jorainer added a commit that referenced this issue Dec 6, 2018
- Add first .collapse_table version (issue #37).
@stanstrup
Copy link
Collaborator

I think I am looking for something similar in the database. It is basically a generalize way to do the synonyms nested column right?

My use case is that I have a list of compounds but only their name and CAS. I will retrieve the structure from databases but I get multiple hits for each CAS. So I want to save the possible structures and curate them from there.

I think you could use

df %>% tidyr::chop(-A) 

instead of .collapse_table.
Unnesting can be done with tidyr::unchop(-A).

Alternative there is also df %>% tidyr::nest(data = -A) that keeps A unique and nests all the rest on one data.frame.

@jorainer
Copy link
Member Author

Thanks. I will look into this.

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