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

Potential helper functions #2

Open
seth127 opened this issue May 31, 2023 · 1 comment
Open

Potential helper functions #2

seth127 opened this issue May 31, 2023 · 1 comment

Comments

@seth127
Copy link
Collaborator

seth127 commented May 31, 2023

Planning to use this issue to add snippets for potential helper functions to consider adding.

@seth127
Copy link
Collaborator Author

seth127 commented May 31, 2023

For seeing which options are specified in a given parse record

get_options_present <- function(record) {
  record$parse()
  purrr::map(record$values, function(x) {
    if(inherits(x, "nmrec_option")) {
      return(x[["name"]])
    } else {
      return(NULL)
    }
  }) %>% 
    purrr::compact() %>% 
    purrr::list_c(ptype = "character")
  
}

Update: This is actually really easy with the $get_options() helper, so maybe not needed

get_options_present2 <- function(record) {
  purrr::map_chr(record$get_options(), ~ .x[["name"]])
}

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

1 participant