Skip to content

Instantly share code, notes, and snippets.

@glamp
Last active December 12, 2015 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save glamp/4750670 to your computer and use it in GitHub Desktop.
Save glamp/4750670 to your computer and use it in GitHub Desktop.
library(stringr)
names(iris)
#[1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
names(iris) <- str_replace_all(names(iris), "[.]", "_")
names(iris)
#[1] "Sepal_Length" "Sepal_Width" "Petal_Length" "Petal_Width" "Species"
s <- c("Go to Heaven for the climate, Hell for the company.")
str_extract_all(s, "[H][a-z]+ ")
#[[1]]
#[1] "Heaven " "Hell "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment