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

Reduce the number of for loops from json_parser #3

Open
PietrH opened this issue Feb 28, 2022 · 1 comment
Open

Reduce the number of for loops from json_parser #3

PietrH opened this issue Feb 28, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request low-priority Lower priority issues

Comments

@PietrH
Copy link
Collaborator

PietrH commented Feb 28, 2022

The JSON parser is difficult to read, it would be good to reduce the number of for loops. I'm going to produce a start for Lynn to have a look at, and see if she wants to further implement it.

The for loops are not currently a breaking issue, so this is low priority.

This is also a demo for Lynn to see how branching and conflict resolution works in GIT.

@PietrH PietrH added enhancement New feature or request low-priority Lower priority issues labels Feb 28, 2022
@PietrH PietrH self-assigned this Feb 28, 2022
@PietrH
Copy link
Collaborator Author

PietrH commented Mar 1, 2022

@LynnDelgat I've put some draft code in https://github.com/LynnDelgat/MIDS-Lynn/blob/pieter-json-parser/src/parse_json_schema_purrr.R

You can adapt it to split conditions as in the current proposal, hopefully it's enough to get you going with purrr and avoiding the if trees in for loops to filter out lists.

Alternatively you might want to write it out using list comprehension: https://cran.r-project.org/web/packages/comprehenr/vignettes/Introduction.html

I would probably fall back on rlang eg. : https://thomasmailund.medium.com/list-comprehension-in-r-3579b6e1dab9, but I find purrr more readable than list comprehensions and I'm not really fluent in them to be honest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low-priority Lower priority issues
Projects
None yet
Development

No branches or pull requests

2 participants