We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Add function to shorten editor names in format lastname, firstname (Rustler, Michael) to lastname firstname (Rustler M.)
lastname, firstname
lastname firstname
To be added here:
kwb.pubs/R/add_kwb-style_to_endnote-db.R
Line 85 in 04bc129
Maybe @hsonne has a nice code chunk for it?
Example dataset attached editors.zip
string <- readRDS(file = "editors.Rds") kwb.pubs:::clean_editors(string)
The text was updated successfully, but these errors were encountered:
Hi @mrustl, here is my proposition, for you to test and integrate:
if (FALSE) { shorten_first_name("Christian") shorten_first_name("Hans-Peter") shorten_first_name("Alfons-Peter Alexander") shorten_first_name("Michael Andreas Oliver") editors <- readRDS("~/../Downloads/S/support/michael-rustler/editors.Rds") abbreviated <- lapply(strsplit(editors, "\r"), function(x) { sapply(x, abbreviate_author, USE.NAMES = FALSE) }) sapply(abbreviated, paste, collapse = "\r") } # abbreviate_author ------------------------------------------------------------ abbreviate_author <- function(x) { last_first <- strsplit(x, "\\s*,\\s*")[[1L]] if (length(last_first) > 1L) { last_first[2L] <- shorten_first_name(last_first[2L]) } paste(last_first, collapse = " ") } # shorten_first_name ----------------------------------------------------------- shorten_first_name <- function(x) { paste(sapply(strsplit(x, "\\s+")[[1]], shorten_dashed_name), collapse = " ") } # shorten_dashed_name ---------------------------------------------------------- shorten_dashed_name <- function(x) { paste(sapply(strsplit(x, "-")[[1]], dot_after_first_char), collapse = "-") } # dot_after_first_char --------------------------------------------------------- dot_after_first_char <- function(x) { paste0(substr(x, 1L, 1L), ".") }
Sorry, something went wrong.
add fix provided by @hsonne
7b268ad
#5 (comment)
@hsonne many thanks!
mrustl
No branches or pull requests
Add function to shorten editor names in format
lastname, firstname
(Rustler, Michael) tolastname firstname
(Rustler M.)To be added here:
kwb.pubs/R/add_kwb-style_to_endnote-db.R
Line 85 in 04bc129
Maybe @hsonne has a nice code chunk for it?
Example dataset attached
editors.zip
The text was updated successfully, but these errors were encountered: