0

After using setindex(dt,col1,col2) to create the secondary indices, how to display the whole data table in col1 and/or col2 order? R examples only show how to extract certain rows based on col1 and/or col2 values.

Thanks in advance.

Jenny
  • 1
  • Please provide a reproducible example by including (1) sample data, (2) code to reproduce what you've done/tried, (3) a clear problem statement including what you'd like to achieve/expected output. Perhaps take a look at how to provide a [minimal reproducible example/attempt](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Maurits Evers Sep 14 '18 at 00:49
  • 1
    Do you just want to look at the data - `print.data.frame(dt)` ? – thelatemail Sep 14 '18 at 01:01
  • 1
    indices don't sort the data in memory -- they only store the sort order to increase efficiency of subsequent operations using sorting. so the way to print in order with indices is the same as without -- only that the sorting will be faster DT[order(index1, index2)] etc. to physically sort, use setkey – MichaelChirico Sep 14 '18 at 01:41

0 Answers0