Skip to content

Instantly share code, notes, and snippets.

@corynissen
Created February 11, 2014 14:19
Show Gist options
  • Save corynissen/8935664 to your computer and use it in GitHub Desktop.
Save corynissen/8935664 to your computer and use it in GitHub Desktop.
bigrams <- function(text){
word.vec <- strsplit(text, "\\s+")[[1]]
word.vec.length <- length(word.vec)
lapply(1:(word.vec.length-1), function(x)c(word.vec[x], word.vec[x+1]))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment