data.table - does setkey(…) create an index or physically reorder the rows in a data table?

后端 未结 1 727
半阙折子戏
半阙折子戏 2021-01-01 17:00

This (very basic) question is the result of an exchange here.

The documentation for setkey() states:

setkey() sorts a data.table

相关标签:
1条回答
  • 2021-01-01 17:21
    1. The rows are sorted. "Changed by reference" here means there is no copying of the entire table and rows are just swapped.

    2. setkey(DT, NULL) is equivalent to setattr(DT, "sorted", NULL). It simply unsets the "sorted" attribute.

    0 讨论(0)
提交回复
热议问题