Subset a data frame using regex matching on the column name and also on the value

Description

Subset a data frame using regex matching on the column name and also on the value

Usage

1
grep_subset(dataFrame, colGrep, subGrep, echo = T, invert = F)

Arguments

dataFrame

is a data.frame

colGrep

is a regex pattern for finding the columns

subGrep

is a regex pattern to subset the values in the matched column

echo

If TRUE, messages are printed on the console

invert

If TRUE, returns everything other than the rows and columns matched using colGrep and subGrep

Examples

1
2
3
4
 
df = data.frame(type = c("sample","event","condition","sample"),value = c("value1","value2",
                 "value3","value4"))
filtered_df = grep_subset(df,"type","sample")                

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.