Skip to content

print.data.table row id in scientific notation #1167

Closed

Description

@jangorecki

The row names while printing, in data.table the row id sequence, is printed in scientific notation. I wonder if it was like that all the time? or maybe it is something which came with 3.2.0?
It is some way confusing as does not distinct the row numbers.

library(data.table)
set.seed(1)
DT <- data.table(a = 1:5, b = letters[1:3], d = rnorm(5*3*1e6))
DT
#          a b          d
#1.0e+00: 1 a -0.6264538
#2.0e+00: 2 b  0.1836433
#3.0e+00: 3 c -0.8356286
#4.0e+00: 4 a  1.5952808
#5.0e+00: 5 b  0.3295078
#      ---               
#1.5e+07: 1 b  0.8778030
#1.5e+07: 2 c -1.8297175
#1.5e+07: 3 a -2.0020279
#1.5e+07: 4 b -0.5252506
#1.5e+07: 5 c -1.5342523
R version 3.2.0 (2015-04-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.2 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_DK.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C              LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] data.table_1.9.5

loaded via a namespace (and not attached):
[1] tools_3.2.0  knitr_1.10.5 chron_2.3-45

Below Frank's comment is related to #1307

Activity

  1. franknarf1 commented on Jun 1, 2015

    @franknarf1
    Contributor

    Yeah, the printing thing is a bug visible in print.data.table. The last line of

    if (isTRUE(row.names)) 
            rownames(toprint) = paste(format(rn, right = TRUE), ":", 
                sep = "")
        else rownames(toprint) = rep.int("", nrow(x))
    

    should refer to nrow(toprint) instead.

    I don't know about the rownumbers-over-1e7 thing. That's the highest I've ever needed to go in practice. I guess the culprit is the format line, but can't figure out how. It shows up the same (with scientific notation) for R 3.0.1.

  2. added a commit that references this issue on Sep 3, 2015
    686a2ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions