Skip to content

Commit a355e1e

Browse files
authored
Apply suggestions from code review
1 parent 0dc09c6 commit a355e1e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

man/IDateTime.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ accounting for both year transitions and varying day counts per week.
217217
}
218218
\references{
219219
220-
G. Grothendieck and T. Petzoldt, "Date and Time Classes in R",
220+
G. Grothendieck and T. Petzoldt, \dQuote{Date and Time Classes in R},
221221
R News, vol. 4, no. 1, June 2004.
222222
223223
H. Wickham, https://gist.github.com/hadley/10238.

man/assign.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ For additional resources, please read \href{../doc/datatable-faq.html}{\code{vig
7575
7676
When \code{LHS} is a factor column and \code{RHS} is a character vector with items missing from the factor levels, the new level(s) are automatically added (by reference, efficiently), unlike base methods.
7777
78-
Unlike \code{<-} for \code{data.frame}, the (potentially large) LHS is not coerced to match the type of the (often small) RHS. Instead the RHS is coerced to match the type of the LHS, if necessary. Where this involves double precision values being coerced to an integer column, a warning is given when fractional data is truncated. It is best to get the column types correct up front and stick to them. Changing a column type is possible but deliberately harder: provide a whole column as the RHS. This RHS is then \emph{plonked} into that column slot and we call this \emph{plonk syntax}, or \emph{replace column syntax} if you prefer. By needing to construct a full length vector of a new type, you as the user are more aware of what is happening and it is clearer to readers of your code that you really do intend to change the column type; e.g., \code{DT[, colA:=as.integer(colA)]}. A plonk occurs whenever you provide a RHS value to \code{:=} which is \code{nrow} long. When a column is \emph{plonked}, the original column is not updated by reference because that would entail updating every single element of that column whereas the plonk is just one column pointer update.
78+
Unlike \samp{<-} for \code{data.frame}, the (potentially large) LHS is not coerced to match the type of the (often small) RHS. Instead the RHS is coerced to match the type of the LHS, if necessary. Where this involves double precision values being coerced to an integer column, a warning is given when fractional data is truncated. It is best to get the column types correct up front and stick to them. Changing a column type is possible but deliberately harder: provide a whole column as the RHS. This RHS is then \emph{plonked} into that column slot and we call this \emph{plonk syntax}, or \emph{replace column syntax} if you prefer. By needing to construct a full length vector of a new type, you as the user are more aware of what is happening and it is clearer to readers of your code that you really do intend to change the column type; e.g., \code{DT[, colA:=as.integer(colA)]}. A plonk occurs whenever you provide a RHS value to \samp{:=} which is \code{nrow} long. When a column is \emph{plonked}, the original column is not updated by reference because that would entail updating every single element of that column whereas the plonk is just one column pointer update.
7979
8080
\code{data.table}s are \emph{not} copied-on-change by \code{:=}, \code{setkey} or any of the other \code{set*} functions. See \code{\link{copy}}.
8181
}

man/setattr.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ setnames(x, old, new, skip_absent=FALSE)
2424
2525
\code{setattr} is a more general function that allows setting of any attribute to an object \emph{by reference}.
2626
27-
A very welcome change in R 3.1+ was that \code{\link[base]{names<-}} and \code{\link[base]{colnames<-}} no longer copy the \emph{entire} object as they used to (up to 4 times), see examples below. They now take a shallow copy. The \code{set*} functions in data.table are still useful because they don't even take a shallow copy. This allows changing names and attributes of a (usually very large) \code{data.table} in the global environment \emph{from within functions}. Like a database.
27+
A very welcome change in R 3.1+ was that \code{\link[base]{names<-}} and \code{\link[base]{colnames<-}} no longer copy the \emph{entire} object as they used to (up to 4 times), see examples below. They now take a shallow copy. The \samp{set*} functions in data.table are still useful because they don't even take a shallow copy. This allows changing names and attributes of a (usually very large) \code{data.table} in the global environment \emph{from within functions}. Like a database.
2828

2929
}
3030
\value{

0 commit comments

Comments
 (0)