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

Question: .required vs required? #184

Open
ramiromagno opened this issue Jun 23, 2023 · 3 comments
Open

Question: .required vs required? #184

ramiromagno opened this issue Jun 23, 2023 · 3 comments

Comments

@ramiromagno
Copy link

Some tib_*() functions accept the parameter required, while others take .required. Why not all .required?

Thanks for this package, I'm loving it!

P.S. btw, is this package meant to offer equivalent functionality to that of {tidyjson}?

@mgirlich
Copy link
Owner

mgirlich commented Jul 7, 2023

I basically follow the design principles of the tidyverse here. E.g. look at dplyr::slice(.data, ..., .by = NULL, .preserve = FALSE) vs dplyr::slice_head(.data, ..., n, prop, by = NULL).
I think it makes sense to follow these design principles but I'm also not quite sure in this case. Always having .required would make things a bit easier.

PS: I think that {tidyjson} has a different idea. It works a bit more like {tidyr} for JSON. {tibblify} on the other hand works on nested lists (that frequently come from JSON) and transforms them into a tibble. There is surely some overlap but the approach is quite different.
My motivation for this package was to transform JSON data from REST apis into a tibble. The tools available back then were too slow (from a computational perspective) and not comfortable to use. I think this package solves both aspects pretty nicely.

@ramiromagno
Copy link
Author

ramiromagno commented Jul 7, 2023

Hi @mgirlich,

Thank you for your answer! A difficult of a tradeoff there indeed...

May I ask another question? Have you considered supporting the specifications in a declarative language, e.g. YAML, that could be compiled ahead of time and then used to transform the lists to tibbles even more efficiently? That would also allow to exchange specs more easily, or even create a data package of specs only.

I mean something like:

# `my_spec` would be an R object with an efficient representation of the "tibblification" required
my_spec <- read_spec(path = "foo_spec.yml")
tibblify(x, my_spec)

@mgirlich
Copy link
Owner

mgirlich commented Jul 7, 2023

Some time ago I added a parser for an OpenAPI spec (parse_openapi_spec()). So this basically supports JSON schema. It surely makes sense to add proper support for JSON schema.

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