Skip to content

Instantly share code, notes, and snippets.

@aghaynes
Created March 2, 2015 10:24
Show Gist options
  • Save aghaynes/80f37df49854dbd8013a to your computer and use it in GitHub Desktop.
Save aghaynes/80f37df49854dbd8013a to your computer and use it in GitHub Desktop.
Search all columns in a dataframe for a piece of text
colsearch <- function(data, query, ignore.case=TRUE){
n <- ncol(data)
c <- character(0)
for(i in 1:n){
if(TRUE %in% grepl(query, unique(data[,i]), ignore.case=ignore.case)) c <- c(c, names(data)[i])
}
c
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment