Skip to content
Prev 393612 / 398503 Next

Removing variables from data frame with a wile card

The -grep(pattern,colnames) as a subscript is a bit dangerous.  If no
colname matches the pattern then all columns will be omitted (because -0 is
the same as 0, which means no column). !grepl(pattern,colnames) avoids this
problem.
data frame with 0 columns and 3 rows
A  B
1 1 11
2 2 12
3 3 13

-Bill
On Fri, Jan 13, 2023 at 11:07 PM Eric Berger <ericjberger at gmail.com> wrote: