Remove Multiple Columns from data.table in R Last Updated : 31 Aug, 2021 Comments Improve Suggest changes Like Article Like Report In this article, we are going to see how to remove multiple columns from data.table in the R Programming language. Create data.table for demonstration: R # load the data.table package library("data.table") # create a data.table with 4 columns # they are id,name,age and address data = data.table(id = c(1,2,3) , name = c("sravan","bobby","satwik"), age = c(23,21,17), address = c("kakumanu","ponnur","hyd")) # display data Output: Here we are going to remove multiple columns by using the index operator [] Syntax: data[ ,':='(column1 = NULL, column2 = NULL, column n=NULL)] where data is the input data.tablecolumn is the columns to be removed:= is the operator to be loaded in the data.table Example 1: R program to remove multiple columns from data.table R # load the data.table package library("data.table") # create a data.table with 4 columns # they are id,name,age and address data = data.table(id = c(1,2,3), name = c("sravan","bobby","satwik"), age = c(23,21,17), address = c("kakumanu","ponnur","hyd")) # remove age , name and address columns data[ ,':='(age = NULL, address = NULL, name=NULL)] # display data Output: Example 2: Remove only one column from data.table R # load the data.table package library("data.table") # create a data.table with 4 columns # they are id,name,age and address data = data.table(id = c(1,2,3), name = c("sravan","bobby","satwik"), age = c(23,21,17), address = c("kakumanu","ponnur","hyd")) # remove id column data[ ,':='(id=NULL)] # display data Output: Example 3: R program to remove all columns R # load the data.table package library("data.table") # create a data.table with 4 columns # they are id,name,age and address data = data.table(id = c(1,2,3), name = c("sravan","bobby","satwik"), age = c(23,21,17), address = c("kakumanu","ponnur","hyd")) # remove all columns data[ ,':='(id=NULL,age = NULL, address = NULL, name=NULL)] # display data Output: Null data.table (0 rows and 0 cols) Comment More infoAdvertise with us Next Article Remove Multiple Columns from data.table in R G gottumukkalabobby Follow Improve Article Tags : R Language R DataTable Similar Reads Group data.table by Multiple Columns in R In this article, we will discuss how to group data.table by multiple columns in R programming language. The package data.table can be used to work with data tables and subsetting and organizing data. It can be downloaded and installed into the workspace using the following command :Â library(data.ta 3 min read Add Multiple New Columns to data.table in R In this article, we will discuss how to Add Multiple New Columns to the data.table in R Programming Language. To do this we will first install the data.table library and then load that library. Syntax: install.packages("data.table") After installing the required packages out next step is to create t 3 min read How to Aggregate multiple columns in Data.table in R ? In this article, we will discuss how to aggregate multiple columns in Data.table in R Programming Language. A data.table contains elements that may be either duplicate or unique. As a result of this, the variables are divided into categories depending on the sets in which they can be segregated. The 5 min read Select Multiple Columns in data.table by Their Numeric Indices in R The data.table package in R is a powerful tool for the data manipulation and analysis. It offers high-performance capabilities for the working with the large datasets and provides the syntax that simplifies data manipulation tasks. One common operation in the data.table is selecting multiple columns 4 min read Import Only Selected Columns of Data from CSV in R In this article, we will be looking at two different approaches to import selected columns of the Data from a CSV file in the R programming language. Method 1: Using read.table() function In this method of only importing the selected columns of the CSV file data, the user needs to call the read.tabl 2 min read Like