Skip to content

Instantly share code, notes, and snippets.

@atbradley
Created July 1, 2013 16:30
Show Gist options
  • Save atbradley/5902375 to your computer and use it in GitHub Desktop.
Save atbradley/5902375 to your computer and use it in GitHub Desktop.
wordcount <- function(str) {
sapply(gregexpr("\\b\\W+\\b", str, perl=TRUE), function(x) sum(x>0) ) + 1
}
@doubleh2
Copy link

nice function, worked perfect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment