-2

Recently I read a R statement somewhere, which said:

mtcars[-1]

What does -1 imply here? I do understand the following statement:

mtcars[1]

which means select the first column from the data frame, but I just could not infer the negative sign in the index?

Jatt
  • 665
  • 2
  • 8
  • 20

1 Answers1

1

Minus means remove the element with that index, just like "no minus" extract that element with the index

kevin
  • 174
  • 6