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

improve bcpc_query() #295

Open
andschar opened this issue Sep 29, 2020 · 1 comment
Open

improve bcpc_query() #295

andschar opened this issue Sep 29, 2020 · 1 comment
Assignees
Labels
consistent api Uniformity across functions and data sources

Comments

@andschar
Copy link
Contributor

aw_query() currently returns a list of lists of vectors, when it finds a match and a vector NA of length 1, if it doesn't. In my opinion this is quite cumbersome to wrangle with in R. Example:

todo = c("630-20-6", "1070-78-6", "1071-83-6", "79-34-5")
aw = webchem::aw_query(todo, from = 'cas')

The first two entries are NA vectors with length 1, the second two entries are lists of vectors. In my opinion it would be better to return a tibble if something is found, because one can use data.table::rbindlist() or dplyr::bind_rows() then. E.g.: data.table::rbindlist(aw[ !is.na(aw) ]). Though, we could also think about returning tibble::tibble(query = '630-20-6') in the case of no match instead of NA, meaning one wouldn't have to exclude NA explicitly when binding. AW returns tabular-freinldy data, so I think it's quite easy to implement the tibbles.

This also belongs to #218.

Also, aw_query() results have the class attribute aw_query assigned. Designed by @Edild to work with the S3-OO system. Should we continue using this? Lately, we haven't made use of any OO-functions. I think we haven't really agreed on that up to now. Also to discuss further in #228.

@andschar andschar added the consistent api Uniformity across functions and data sources label Sep 29, 2020
@andschar andschar self-assigned this Sep 29, 2020
@Aariq Aariq changed the title improve aw_query() improve bcpc_query() Jan 5, 2022
@Aariq
Copy link
Collaborator

Aariq commented Jan 5, 2022

Just wanted to note that this still applies to bcpc_query()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consistent api Uniformity across functions and data sources
Projects
None yet
Development

No branches or pull requests

2 participants