Skip to content

Commit

Permalink
proper NA handling in as.ITime.character, closes #2940 (#2941)
Browse files Browse the repository at this point in the history
  • Loading branch information
jangorecki authored and mattdowle committed Aug 14, 2018
1 parent d97896d commit 2814c81
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

2. `gmin` and `gmax` no longer fail on _ordered_ factors, [#1947](https://github.com/Rdatatable/data.table/issues/1947). Thanks to @mcieslik-mctp for identifying and @mbacou for the nudge.

3. `as.ITime.character` now properly handles NA when attempting to detect the format of non-NA values in vector. Thanks @polyjian for reporting, closes [#2940](https://github.com/Rdatatable/data.table/issues/2940).

#### NOTES

1. The type coercion warning message has been improved, [#2989](https://github.com/Rdatatable/data.table/pull/2989). Thanks to @sarahbeeysian on [Twitter](https://twitter.com/sarahbeeysian/status/1021359529789775872) for highlighting. For example, given the follow statements:
Expand Down
2 changes: 1 addition & 1 deletion R/IDateTime.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ as.ITime.character <- function(x, format, ...) {
new <- strptime(x[w], format = f, ...)
nna <- !is.na(new)
if (any(nna)) {
y[ w[nna] ] <- new
y[ w[nna] ] <- new[nna]
w <- w[!nna]
}
}
Expand Down
3 changes: 3 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -12020,6 +12020,9 @@ test(1918.5, DT[, min(V1), by=V2], data.table(V2=c("f", "g", "h"), V1=structure(
test(1918.6, DT[, max(V1), by=V2], data.table(V2=c("f", "g", "h"), V1=structure(3:5, .Label=lev, class=c("ordered", "factor"))))
options(old)

# as.ITime.character bug for NA handling #2940
test(1919, as.ITime(c('xxx', '10:43')), structure(c(NA, 38580L), class = "ITime"))

###################################
# Add new tests above this line #
###################################
Expand Down

0 comments on commit 2814c81

Please sign in to comment.