Here are two ways to remove columns 'a' and 'c' from a data frame df
in R:
main.r42 chars2 lines
This code subsets df
by selecting all columns except those whose names are 'a' or 'c'.
select()
function from the dplyr package:main.r40 chars3 lines
This code uses the select()
function to select all columns from df
except those named 'a' or 'c'. The -
before column names means to exclude them.
Either way, df
will be modified to contain all columns except 'a' and 'c'.
gistlibby LogSnag