R/make_name_surname.R

#' Put author names in "Name Surname" format
#'
#' Put author names in "Name Surname" format
#'
#' @param x string containing author name, either in "Surname, Name" or "Name Surname" format
#'
#' @return string containing author name in "Name Surname" format

make_name_surname <- function(x){
  s <- strsplit(x, ",")[[1]]
  if (length(s) == 2) s <- paste(s[2], s[1])
  return(sub("^\\s+", "", s))
}

Try the ChocoLattes package in your browser

Any scripts or data that you put into this service are public.

ChocoLattes documentation built on May 2, 2019, 3:24 a.m.