Skip to content

Commit 659d464

Browse files
ben-schwenBenjamin Schwendinger
andauthored
add examples to insert new column as first/last column (#5673)
* add examples to insert new column as first/last column Co-authored-by: Benjamin Schwendinger <[email protected]>
1 parent 4bc10a6 commit 659d464

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132

133133
23. `DT[, head(.SD,n), by=grp]` and `tail` are now optimized when `n>1`, [#5060](https://github.com/Rdatatable/data.table/issues/5060) [#523](https://github.com/Rdatatable/data.table/issues/523#issuecomment-162934391). `n==1` was already optimized. Thanks to Jan Gorecki and Michael Young for requesting, and Benjamin Schwendinger for the PR.
134134

135-
24. `setcolorder()` gains `before=` and `after=`, [#4385](https://github.com/Rdatatable/data.table/issues/4358). Thanks to Matthias Gomolka for the request, and both Benjamin Schwendinger and Xianghui Dong for implementing.
135+
25. `setcolorder()` gains `before=` and `after=`, [#4385](https://github.com/Rdatatable/data.table/issues/4358). Thanks to Matthias Gomolka for the request, and both Benjamin Schwendinger and Xianghui Dong for implementing. Also thanks to Manuel López-Ibáñez for testing dev and mentioning needed documentation before release.
136136

137137
25. `base::droplevels()` gains a fast method for `data.table`, [#647](https://github.com/Rdatatable/data.table/issues/647). Thanks to Steve Lianoglou for requesting, Boniface Kamgang and Martin Binder for testing, and Jan Gorecki and Benjamin Schwendinger for the PR. `fdroplevels()` for use on vectors has also been added.
138138

man/setcolorder.Rd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ setcolorder(DT, c("C", "A", "B"))
3434

3535
#incomplete specification
3636
setcolorder(DT, "A")
37+
38+
# insert new column as first column
39+
set(DT, j="D", value=sample(10))
40+
setcolorder(DT, "D", before=1)
41+
42+
# move column to last column place
43+
setcolorder(DT, "A", after=ncol(DT))
3744
}
3845
\keyword{ data }
3946

0 commit comments

Comments
 (0)