6

I have a data table with 5778 rows and 28 columns. How do I delete ALL of the 1st row. E.g. let's say the data table had 3 rows and 4 columns and looked like this:

Row number tracking_id    3D71    3D72  3D73
    1          xxx         1       1     1
    2          yyy         2       2     2
    3          zzz         3       3     3

I want to create a data table that looks like this:

    Row number tracking_id    3D71    3D72  3D73
    1          yyy             2       2     2
    2          zzz             3       3     3

i.e. I want to delete all of row number 1 and then shift the other rows up.

I have tried datatablename[-c(1)] but this deletes the first column not the first row!

Many thanks for any help!

Jaap
  • 81,064
  • 34
  • 182
  • 193
lharrisl
  • 63
  • 1
  • 1
  • 4

2 Answers2

9

You can do this via

dataframename = dataframename[-1,]
Jonathan Rhein
  • 1,616
  • 3
  • 23
  • 47
1

It can be easily done with indexing the data.table/data frame as mentioned by @joni. You can also do with

datatablename <- datatablename[2:nrow(datatablename), ]

You can find more interesting stuff about data.table here.

Arun
  • 116,683
  • 26
  • 284
  • 387
Fitzerbirth
  • 133
  • 10