Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

### NEW FEATURES

1. `nafill()`, `setnafill()` extended to work on logical and factor vectors (part of [#3992](https://github.com/Rdatatable/data.table/issues/3992)). Includes support for `Date`, `IDate`, `POSIXct`, etc. `nafill()` works for character vectors, but not yet `setnafill()`. Thanks @jangorecki for the request and @jangorecki and @MichaelChirico for the PRs.
1. `nafill()`, `setnafill()` extended to work on logical, factor and character vectors (part of [#3992](https://github.com/Rdatatable/data.table/issues/3992)). Includes support for `Date`, `IDate`, `POSIXct` and character vectors. Thanks @jangorecki for the request and @jangorecki, @MichaelChirico and @ben-schwen for the PRs.

2. `[,showProgress=]` and `options(datatable.showProgress)` now accept an integer to control the progress bar update interval in seconds, allowing finer control over progress reporting frequency; `TRUE` uses the default 3-second interval, [#6514](https://github.com/Rdatatable/data.table/issues/6514). Thanks @ethanbsmith for the report and @ben-schwen for the PR.

Expand Down
17 changes: 12 additions & 5 deletions inst/tests/nafill.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,15 @@ test(16.07, setnafill(copy(DT), fill="a", cols='f1')$f1,
test(16.08, setnafill(copy(DT), fill="a", cols=c('f1', 'f2'))[, .(f1, f2)],
data.table(f1=as.factor(c("a", "a", "a", "b", "a", "a", "b", "c", "a", "a")),
f2=as.factor(c("a", "a", "c", "b", "a", "a", "b", "a", "a", "a"))))
test(16.09, setnafill(DT, fill="z", cols='c1'), error="not yet supported")
# test(16.10, setnafill(copy(DT), fill="z", cols=c('c1', 'c2'))[, .(c1, c2)],
# data.table(c1=c("z", "z", "a", "b", "z", "z", "c", "d", "z", "z"),
# c2=c("z", "z", "d", "c", "z", "z", "b", "a", "z", "z")))
test(16.09, setnafill(copy(DT), fill="z", cols='c1')$c1,
c("z", "z", "a", "b", "z", "z", "c", "d", "z", "z"))
test(16.10, setnafill(copy(DT), fill="z", cols=c('c1', 'c2'))[, .(c1, c2)],
data.table(c1=c("z", "z", "a", "b", "z", "z", "c", "d", "z", "z"),
c2=c("z", "z", "d", "c", "z", "z", "b", "a", "z", "z")))
test(16.101, setnafill(copy(DT), type="locf", cols='c1')$c1,
c(NA, NA, "a", "b", "b", "b", "c", "d", "d", "d"))
test(16.102, setnafill(copy(DT), type="nocb", cols='c1')$c1,
c("a", "a", "a", "b", "c", "c", "c", "d", NA, NA))
test(16.11, setnafill(copy(DT), fill=as.POSIXct("2027-01-01"), cols='t1')$t1,
replace(DT$t1, c(1:2, 5:6, 9:10), as.POSIXct("2027-01-01")))
test(16.12, setnafill(copy(DT), fill=as.POSIXct("2027-01-01"), cols=c('t1', 't2'))[, .(t1, t2)],
Expand All @@ -467,7 +472,9 @@ test(16.13, setnafill(copy(DT), fill=list(TRUE, 9L, 9.0, "a", as.POSIXct("2027-0
d1=c(9.0, 9L, 0L, 1L, 9L, 9L, 2:3, 9L, 9L),
f1=as.factor(c("a", "a", "a", "b", "a", "a", "b", "c", "a", "a")),
t1=replace(DT$t1, c(1:2, 5:6, 9:10), as.POSIXct("2027-01-01"))))
test(16.14, setnafill(DT, cols=c("l1", "c1")), error="not yet supported")
test(16.14, setnafill(copy(DT), fill=list(TRUE, "z"), cols=c("l1", "c1"))[, .(l1, c1)],
data.table(l1=c(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE),
c1=c("z", "z", "a", "b", "z", "z", "c", "d", "z", "z")))
DT = data.table(l=c(NA, FALSE), i=c(NA, 0L))
setnafill(DT, fill=list(TRUE, 1L))
test(16.15, DT, data.table(l=c(TRUE, FALSE), i=1:0))
Expand Down
5 changes: 2 additions & 3 deletions src/nafill.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,10 @@ SEXP nafillR(SEXP obj, SEXP type, SEXP fill, SEXP nan_is_na_arg, SEXP inplace, S
}
vans[i] = ((ans_t) { .dbl_v=(double *)p, .int_v=(int *)p, .int64_v=(int64_t *)p, .char_v=(SEXP)p, .status=0, .message={"\0","\0","\0","\0"} });
}
} else if (any_char) {
error(_("In-place filling of character columns is not yet supported."));
} else {
for (R_len_t i=0; i<nx; i++) {
vans[i] = ((ans_t) { .dbl_v=dx[i], .int_v=ix[i], .int64_v=i64x[i], .status=0, .message={"\0","\0","\0","\0"} });
SEXP xi = VECTOR_ELT(x, i);
vans[i] = ((ans_t) { .dbl_v=dx[i], .int_v=ix[i], .int64_v=i64x[i], .char_v=isString(xi) ? xi : R_NilValue, .status=0, .message={"\0","\0","\0","\0"} });
Comment thread
jangorecki marked this conversation as resolved.
}
}

Expand Down
Loading