How to delete the first row of a dataframe in R?

R Programming

I have a dataset with 11 columns with over a 1000 rows each. The columns were labeled V1, V2, V11, etc.. I replaced the names with something more useful to me using the "c" command. I didn't realize that row 1 also contained labels for each column and my actual data starts on row 2.

Is there a way to delete row 1 and decrement?

If you want to unleash your potential in this competitive field, please visit the R Programming course page for more information, where you can find the R Programming tutorials and R Programming frequently asked interview questions and answers as well.



To remove rows, you can use the negative index. Use the below command to remove the first row in your data frame.

data <- data[-1, ]

This will delete the 1st row. And your row 2 will become the first row.


If you are reading the data from a file, it is recommended to use header = TRUE while you read data into a data frame. It will consider the 1st row as headers.

df = read.table('<file>', header = T)


This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.
To Top