How to Delete Row(s) in R DataFrame ? Last Updated : 09 May, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how row(s) can be deleted from a Dataframe in R Programming Language. Deleting a single row For this, the index of the row to be deleted is passed with a minus sign. Syntax: df[-(index), ] Example 1 : R # creating a data frame with # some data . df=data.frame(id=c(1,2,3), name=c("karthik","sravan","nikhil"), branch=c("IT","IT","CSE")) # using - with indexing deleting # 3rd row . df[-3,] Output : Example 2 : R # creating a data frame with # some data . df=data.frame(id=c(1,2,3), name=c("karthik","sravan","nikhil"), branch=c("IT","IT","CSE")) # using - with indexing deleting # 2nd row df[-2,] Output : Deleting multiple rows Method 1: Using Range For this, the range of the rows to be deleted is passed to the dataframe name. Syntax: df[-(start_index,end_index), ] Example 1: R # creating a data frame with # some data df=data.frame(id=c(1,2,3,4,5), name=c("karthik","sravan","nikhil", "bhagiradh","sai"), branch=c("IT","IT","CSE","IT","CSE")) # deleting multiple rows using # vector df[-c(3,5),] Output: Example 2: R # creating a data frame with # some data df=data.frame(id=c(1,2,3,4,5), name=c("karthik","sravan","nikhil", "bhagiradh","sai"), branch=c("IT","IT","CSE","IT","CSE")) # deleting multiple rows using # vector df[-c(2,4),] Output : Method 2: Using anti_join( ) anti_join method is available in dplyr package. So we have to install dplyr package first. To install we can use install.package() method, and we have to pass package name as parameter. To import the package into the R environment we need to use library( ) function. In this function, we have to pass the package name as a parameter. Syntax : anti_join (data_frame_name , data_frame_name [ c(row_index 1 ,...row_index n),c( column_index 1,......column_index n)] ) Example 1 : R library(dplyr) # creating a data frame with some data df=data.frame(id=c(1,2,3,4,5), name=c("karthik","sravan","nikhil", "bhagiradh","sai"), branch=c("IT","IT","CSE","IT","CSE")) anti_join(df,df[c(1,2),]) Output : Example 2: R library(dplyr) # creating a data frame with # some data df=data.frame(id=c(1,2,3,4,5), name=c("karthik","sravan","nikhil", "bhagiradh","sai"), branch=c("IT","IT","CSE","IT","CSE")) anti_join(df,df[c(1,3),]) Output : Comment More infoAdvertise with us Next Article How to Delete Row(s) in R DataFrame ? K krishnakarthikeyakhandrika Follow Improve Article Tags : R Language R Programs R-DataFrame R DataFrame-Programs Similar Reads How to Remove Duplicate Rows in R DataFrame? In this article, we will discuss how to remove duplicate rows in dataframe in R programming language. Dataset in use:Method 1: Using distinct() This method is available in dplyr package which is used to get the unique rows from the dataframe. We can remove rows from the entire which are duplicates a 2 min read How to Remove Rows in R DataFrame? In this article, we will discuss how to remove rows from dataframe in the R programming language. Method 1: Remove Rows by Number By using a particular row index number we can remove the rows. Syntax: data[-c(row_number), ] where. data is the input dataframerow_number is the row index position Exam 2 min read How to add Header to Dataframe in R ? A header necessarily stores the names or headings for each of the columns. It basically helps the user to identify the role of the respective column in the data frame. The top row containing column names is called the header row of the data frame. In this article, we will learn how to add a Header t 3 min read How to delete rows of R dataframe based on string match? In this article, we will discuss how to delete rows of a dataframe based on string match in R Programming Language. For this grep() function can be used. This function searches for matches of certain character patterns in a vector of character strings and returns a boolean value as TRUE if that stri 1 min read How to Unnest dataframe in R ? In this article, we will discuss how to unnest dataframes in R Programming Language. Unnesting of dataframe refers to flattening it. Method 1: Using do.call approach The do.call() method in base R constructs and executes a function call from a function using its corresponding argument list. Syntax 3 min read Like