Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdowle committed Apr 16, 2021
1 parent 98e605f commit 662bac4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

2. `print(DT, trunc.cols=TRUE)` and the corresponding `datatable.print.trunc.cols` option (new feature 3 in v1.13.0) could display an extra `diff.prev` column, [#4266](https://github.com/Rdatatable/data.table/issues/4266). Thanks to @tdhock for the PR.

3. According to documentation of `fread`, using it with parameter `nrows=0` returns the column names and typed empty columns determined by the large sample. However, this only worked for `0` and was treating `0L` like `nrows=Inf`. Thanks to @hongyuanjia for pointing this out and thanks to Benjamin Schwendinger for fixing it.
3. `fread(..., nrows=0L)` now works as intended and the same as `nrows=0`; i.e. returning the column names and typed empty columns determined by the large sample, [#4686](https://github.com/Rdatatable/data.table/issues/4686). Thanks to @hongyuanjia for reporting, and Benjamin Schwendinger for the PR.

## NOTES

Expand Down
2 changes: 1 addition & 1 deletion R/fread.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ yaml=FALSE, autostart=NA, tmpdir=tempdir(), tz="UTC")
isTRUEorFALSE(verbose), isTRUEorFALSE(check.names), isTRUEorFALSE(logical01), isTRUEorFALSE(keepLeadingZeros), isTRUEorFALSE(yaml) )
stopifnot( isTRUEorFALSE(stringsAsFactors) || (is.double(stringsAsFactors) && length(stringsAsFactors)==1L && 0.0<=stringsAsFactors && stringsAsFactors<=1.0))
stopifnot( is.numeric(nrows), length(nrows)==1L )
nrows=as.double(nrows) #4686
if (is.na(nrows) || nrows<0) nrows=Inf # accept -1 to mean Inf, as read.table does
nrows=as.numeric(nrows) #4686
if (identical(header,"auto")) header=NA
stopifnot(is.logical(header) && length(header)==1L) # TRUE, FALSE or NA
stopifnot(is.numeric(nThread) && length(nThread)==1L)
Expand Down
8 changes: 4 additions & 4 deletions src/freadR.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ SEXP freadR(
else if (LOGICAL(headerArg)[0]==TRUE) args.header = true;

args.nrowLimit = INT64_MAX;
// checked at R level
if (isReal(nrowLimitArg)) {
if (R_FINITE(REAL(nrowLimitArg)[0]) && REAL(nrowLimitArg)[0]>=0.0) args.nrowLimit = (int64_t)(REAL(nrowLimitArg)[0]);
}
if (!isReal(nrowLimitArg) || length(nrowLimitArg)!=1)
error(_("Internal error: freadR nrows not a single real. R level catches this.")); // # nocov
if (R_FINITE(REAL(nrowLimitArg)[0]) && REAL(nrowLimitArg)[0]>=0.0)
args.nrowLimit = (int64_t)(REAL(nrowLimitArg)[0]);

args.logical01 = LOGICAL(logical01Arg)[0];
{
Expand Down

0 comments on commit 662bac4

Please sign in to comment.