Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

5. `fwrite(x, row.names=TRUE)` with `x` a `matrix` writes `row.names` when present, not row numbers, [#5315](https://github.com/Rdatatable/data.table/issues/5315). Thanks to @Liripo for the report, and @ben-schwen for the fix.

6. `round()` method for `IDate` has more natural behavior for `"weeks"` -- in particular, the first week of the year will always have 7 days instead of 6, [#4334](https://github.com/Rdatatable/data.table/pull/4334). Thanks @artemklevtsov for the report and fix.

## NOTES

1. `transform` method for data.table sped up substantially when creating new columns on large tables. Thanks to @OfekShilon for the report and PR. The implemented solution was proposed by @ColeMiller1.
Expand Down
2 changes: 1 addition & 1 deletion R/IDateTime.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ as.list.IDate = function(x, ...) NextMethod()
round.IDate = function (x, digits=c("weeks", "months", "quarters", "years"), ...) {
units = match.arg(digits)
as.IDate(switch(units,
weeks = round(x, "year") + 7L * (yday(x) %/% 7L),
weeks = round(x, "year") + 7L * ((yday(x) - 1L) %/% 7L),
months = ISOdate(year(x), month(x), 1L),
quarters = ISOdate(year(x), 3L * (quarter(x)-1L) + 1L, 1L),
years = ISOdate(year(x), 1L, 1L)))
Expand Down
2 changes: 1 addition & 1 deletion inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -12446,7 +12446,7 @@ test_dates = c(
)
test_dates = as.IDate(test_dates)
test(1872.03, round(test_dates, 'weeks'),
structure(c(17167L, 17377L, 17321L, 17272L, 17328L,
structure(c(17167L, 17377L, 17321L, 17265L, 17328L,
17440L, 17272L, 17174L, 17230L, 17447L),
class = c("IDate", "Date")))
test(1872.04, round(test_dates, 'months'),
Expand Down