Learn R Programming

mtconnectR (version 1.2.1)

grep_subset: 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

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

Run this code
# NOT RUN {
 
df = data.frame(type = c("sample","event","condition","sample"),value = c("value1","value2",
                 "value3","value4"))
filtered_df = grep_subset(df,"type","sample")                
# }

Run the code above in your browser using DataLab