I found a simple answer using dplyr
/tidyverse
. If your colnames
contain “This”, then all variables containing “This” will be dropped.
library(dplyr)
df_new <- df %>% select(-contains("This"))
More Related Contents:
- Select rows from a data frame based on values in a vector
- Round up from .5
- What does “The following object is masked from ‘package:xxx'” mean?
- Replace NA in column with value in adjacent column
- Remove columns with zero values from a dataframe
- How to display the frequency at the top of each factor in a barplot in R [duplicate]
- efficiently generate a random sample of times and dates between two dates
- Export data from R to Excel
- Create new dummy variable columns from categorical variable
- How to draw lines outside of plot area in ggplot2?
- drop-down checkbox input in shiny
- dplyr on data.table, am I really using data.table?
- Marker mouse click event in R leaflet for shiny
- how to show a legend on dual y-axis ggplot
- Different colours of geom_line above and below a specific value
- use ggpairs to create this plot
- How to make grouped layout in igraph?
- Update handsontable by editing table and/or eventReactive
- Why is as.Date slow on a character vector?
- Alternative to expand.grid for data.frames
- Changing Million/Billion abbreviations into actual numbers? ie. 5.12M -> 5,120,000 [duplicate]
- Apply a function to a subset of data.table columns, by column-indices instead of name
- Creating (and Accessing) a Sparse Matrix with NA default entries
- Calculate Euclidean distance matrix using a big.matrix object
- Deleting specific rows from a data frame
- Specify height and width of ggplot graph in Rmarkdown knitr output
- Merge dataframes, different lengths
- Dealing with spaces and “weird” characters in column names with dplyr::rename()
- How to get all possible subsets of a character vector in R?
- Filtering rows in R unexpectedly removes NAs when using subset or dplyr::filter