Skip to content

Commit

Permalink
avoid with=FALSE in doc example (#5594)
Browse files Browse the repository at this point in the history
* avoid with=FALSE in doc example

* Use Tyson suggestion
  • Loading branch information
MichaelChirico authored Dec 14, 2023
1 parent 3bd4fd1 commit 7f5498a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion man/setcolorder.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ setcolorder(x, neworder=key(x), before=NULL, after=NULL)
\item{before, after}{ If one of them (not both) was provided with a column name or number, \code{neworder} will be inserted before or after that column. }
}
\details{
To reorder \code{data.table} columns, the idiomatic way is to use \code{setcolorder(x, neworder)}, instead of doing \code{x <- x[, neworder, with=FALSE]}. This is because the latter makes an entire copy of the \code{data.table}, which maybe unnecessary in most situations. \code{setcolorder} also allows column numbers instead of names for \code{neworder} argument, although we recommend using names as a good programming practice.
To reorder \code{data.table} columns, the idiomatic way is to use \code{setcolorder(x, neworder)}, instead of doing \code{x <- x[, ..neworder]} (or \code{x <- x[, neworder, with=FALSE]}). This is because the latter makes an entire copy of the \code{data.table}, which maybe unnecessary in most situations. \code{setcolorder} also allows column numbers instead of names for \code{neworder} argument, although we recommend using names as a good programming practice.
}
\value{
The input is modified by reference, and returned (invisibly) so it can be used in compound statements. If you require a copy, take a copy first (using \code{DT2 = copy(DT)}). See \code{?copy}.
Expand Down

0 comments on commit 7f5498a

Please sign in to comment.