Skip to content

Instantly share code, notes, and snippets.

@mhkeller
Forked from abelsonlive/gist:4726453
Created February 7, 2013 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhkeller/4729318 to your computer and use it in GitHub Desktop.
Save mhkeller/4729318 to your computer and use it in GitHub Desktop.
d <- read.csv("all_posts.csv", stringsAsFactors=F)
pattern <- "regex here"
d$guns <- 0
d$guns[grep(pattern, d$text)] <- 1
d_guns <- d[d$guns==1,]
write.csv(d_guns, "gun_posts.csv", row.names=F)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment