Skip to content

Instantly share code, notes, and snippets.

@ajatoledo
Created October 25, 2017 03:20
Show Gist options
  • Save ajatoledo/7599489333ced8435e196658ac59e3c7 to your computer and use it in GitHub Desktop.
Save ajatoledo/7599489333ced8435e196658ac59e3c7 to your computer and use it in GitHub Desktop.
This is a simply function that can be called to format a vector of first name, middle name, surname vectors. Note that this does NOT account for any surnames that required lowercase first letters for proper formatting.
proper_name_formatting <- function(x) {
y <- strsplit(x, " ")[[1]]
paste(toupper(substring(y, 1,1)), substring(y, 2),
sep="", collapse=" ")
}
# below is an example for how to use the function
# usages is sapply(x, proper_name_formatting)
# hello_world <- c("hello world)
# sapply(hello_world, proper_name_formatting) -> Hello World
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment