To remove multiple columns from a data frame in R, you can use the dplyr package's select()
function to select only the columns you want to keep.
Here's an example using the mtcars
dataset:
main.r205 chars9 lines
In this example, we used the -
operator to exclude the columns we want to remove. The resulting data frame mtcars_new
only contains the columns that were not removed.
gistlibby LogSnag