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 contributors() function #136

Open
2 tasks done
peterdesmet opened this issue Oct 17, 2024 · 1 comment · May be fixed by #140
Open
2 tasks done

Create contributors() function #136

peterdesmet opened this issue Oct 17, 2024 · 1 comment · May be fixed by #140

Comments

@peterdesmet
Copy link
Member

peterdesmet commented Oct 17, 2024

Cf. taxonomic() to retrieve the x$contributors as a data frame. This is useful for user to see who's currently listed. Longer term, we could either add a contributors()<- or update_contributors().

  • Code is already in write_eml() and can be called there:

camtrapdp/R/write_eml.R

Lines 94 to 120 in 80e0674

creators <-
purrr::map_dfr(
x$contributors,
~ as.data.frame(., stringsAsFactors = FALSE)
) %>%
dplyr::filter(!.data$role %in% c("rightsHolder", "publisher")) %>%
mutate_when_missing(path = character()) %>% # Guarantee path col
dplyr::mutate(
first_name = purrr::map_chr(
.data$title,
~ strsplit(.x, " ", fixed = TRUE)[[1]][1] # First string before space
),
last_name = purrr::map_chr(
.data$title,
~ sub("^\\S* ", "", .x) # Remove string up until first space
),
orcid = ifelse( # Move ORCID from path to separate column
!is.na(regexpr(orcid_regex, .data$path)),
regmatches(.data$path, regexpr(orcid_regex, .data$path)),
NA_character_
),
path = ifelse(
grepl(orcid_regex, .data$path),
NA_character_,
.data$path
)
)

  • I would then also update create_eml_contributors() in utils to work with a df rather than a list.
@peterdesmet
Copy link
Member Author

We could also add this function to frictionless-r, but I wonder if it is generic enough.

@sannegovaert sannegovaert linked a pull request Nov 5, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant