From 686a2ec888998a021b026ab5ab04c02bdc6a9199 Mon Sep 17 00:00:00 2001 From: jangorecki Date: Thu, 3 Sep 2015 01:08:15 +0100 Subject: [PATCH] print.data.table in non-scientific numbers, closes #1167 --- R/data.table.R | 2 +- README.md | 2 ++ inst/tests/tests.Rraw | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/R/data.table.R b/R/data.table.R index d154b3e858..d8def75a8e 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -136,7 +136,7 @@ print.data.table <- function(x, } toprint=format.data.table(toprint, ...) # FR #5020 - add row.names = logical argument to print.data.table - if (isTRUE(row.names)) rownames(toprint)=paste(format(rn,right=TRUE),":",sep="") else rownames(toprint)=rep.int("", nrow(x)) + if (isTRUE(row.names)) rownames(toprint)=paste(format(rn,right=TRUE,scientific=FALSE),":",sep="") else rownames(toprint)=rep.int("", nrow(x)) if (is.null(names(x))) colnames(toprint)=rep("NA", ncol(toprint)) # fixes bug #4934 if (printdots) { toprint = rbind(head(toprint,topn),"---"="",tail(toprint,topn)) diff --git a/README.md b/README.md index d61e4a9f19..9fdc1b543e 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,8 @@ 61. `merge.data.table()` didn't set column order (and therefore names) properly in some cases. Fixed now. Closes [#1290](https://github.com/Rdatatable/data.table/issues/1290). Thanks to @ChristK for the minimal example. + 63. Printing data.table will not print row numbers in scientific notation. Closes [#1167](https://github.com/Rdatatable/data.table/issues/1167). Thanks to @jangorecki. + #### NOTES 1. Clearer explanation of what `duplicated()` does (borrowed from base). Thanks to @matthieugomez for pointing out. Closes [#872](https://github.com/Rdatatable/data.table/issues/872). diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index f8e7a47623..a6c0a00034 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -6775,6 +6775,13 @@ text="A,B\ną,ž\nū,į\nų,ė\nš,ę\n" test(1548.1, unique(unlist(lapply(fread(text, sep=",", header=TRUE), Encoding))), "unknown") test(1548.2, unique(unlist(lapply(fread(text, sep=",", header=TRUE, encoding="UTF-8"), Encoding))), "UTF-8") test(1548.3, fread(text, sep=",", encoding="UTF-8", data.table=FALSE), read.table(text=text, sep=",", header=TRUE, encoding="UTF-8", stringsAsFactors=FALSE)) + +# #1167 print.data.table row id in non-scientific notation +DT <- data.table(a = rep(1:5,3*1e6), b = rep(letters[1:3],5*1e6)) +test(1549, capture.output(print(DT)), c(" a b", " 1: 1 a", " 2: 2 b", " 3: 3 c", " 4: 4 a", " 5: 5 b", " --- ", "14999996: 1 b", "14999997: 2 c", "14999998: 3 a", "14999999: 4 b", "15000000: 5 c")) +rm(DT) + + ##########################