|
81 | 81 |
|
82 | 82 | 12. New `cbindlist()` and `setcbindlist()` for concatenating a `list` of data.tables column-wise, evocative of the analogous `do.call(rbind, l)` <-> `rbindlist(l)`, [#2576](https://github.com/Rdatatable/data.table/issues/2576). `setcbindlist()` does so without making any copies. Thanks @MichaelChirico for the FR, @jangorecki for the PR, and @MichaelChirico for extensive reviews and fine-tuning. |
83 | 83 |
|
| 84 | + ```r |
| 85 | + l = list( |
| 86 | + data.table(id = 1:3, a = letters[1:3]), |
| 87 | + data.table(b = 4:6, c = 7:9) |
| 88 | + ) |
| 89 | + cbindlist(l) |
| 90 | + # id a b c |
| 91 | + # 1: 1 a 4 7 |
| 92 | + # 2: 2 b 5 8 |
| 93 | + # 3: 3 c 6 9 |
| 94 | + ``` |
| 95 | + |
84 | 96 | 13. New `mergelist()` and `setmergelist()` similarly work _a la_ `Reduce()` to recursively merge a `list` of data.tables, [#599](https://github.com/Rdatatable/data.table/issues/599). Different join modes (_left_, _inner_, _full_, _right_, _semi_, _anti_, and _cross_) are supported through the `how` argument; duplicate handling goes through the `mult` argument. `setmergelist()` carefully avoids copies where one is not needed, e.g. in a 1:1 left join. Thanks Patrick Nicholson for the FR (in 2013!), @jangorecki for the PR, and @MichaelChirico for extensive reviews and fine-tuning. |
85 | 97 |
|
| 98 | +```r |
| 99 | + l = list( |
| 100 | + data.table(id = c(1L, 2L, 3L), x = c("a", "b", "c")), |
| 101 | + data.table(id = c(1L, 2L, 4L), y = c("d", "e", "f")), |
| 102 | + data.table(id = c(1L, 3L, 4L), z = c("g", "h", "i")) |
| 103 | + ) |
| 104 | + |
| 105 | + # Recursive inner join |
| 106 | + mergelist(l, on = "id", how = "inner") |
| 107 | + # id x y z |
| 108 | + # 1: 1 a d g |
| 109 | + |
| 110 | + # Recursive left join (the default 'how') |
| 111 | + mergelist(l, on = "id", how = "left") |
| 112 | + # id x y z |
| 113 | + # 1: 1 a d g |
| 114 | + # 2: 2 b e <NA> |
| 115 | + # 3: 3 c <NA> h |
| 116 | + ``` |
| 117 | + |
86 | 118 | 14. `fcoalesce()` and `setcoalesce()` gain `nan` argument to control whether `NaN` values should be treated as missing (`nan=NA`, the default) or non-missing (`nan=NaN`), [#4567](https://github.com/Rdatatable/data.table/issues/4567). This provides full compatibility with `nafill()` behavior. Thanks to @ethanbsmith for the feature request and @Mukulyadav2004 for the implementation. |
87 | 119 |
|
88 | 120 | 15. New function `isoyear()` has been implemented as a complement to `isoweek()`, returning the ISO 8601 year corresponding to a given date, [#7154](https://github.com/Rdatatable/data.table/issues/7154). Thanks to @ben-schwen and @MichaelChirico for the suggestion and @venom1204 for the implementation. |
|
0 commit comments