Skip to content

Commit

Permalink
Closes #939, clarified the recent change to := print behaviour in FAQ.
Browse files Browse the repository at this point in the history
  • Loading branch information
arunsrinivasan committed Mar 9, 2016
1 parent a2cb83a commit 4a5c85d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vignettes/datatable-faq.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ The whole of `DT` is returned (now invisibly) so that compound syntax can work;

To solve this problem, the key was to stop trying to stop the print method running after a `:=`. Instead, inside `:=` we now (from v1.8.3) set a global flag which the print method uses to know whether to actually print or not.

## Why do I have to type `DT` sometimes twice after using `:=` to print the result to console?

This is an unfortunate downside to get [#869](https://github.com/Rdatatable/data.table/issues/869) to work. If a `:=` is used inside a function with no `DT[]` before the end of the function, then the next time `DT` is typed at the prompt, nothing will be printed. A repeated `DT` will print. To avoid this: include a `DT[]` after the last `:=` in your function. If that is not possible (e.g., it's not a function you can change) then `print(DT)` and `DT[]` at the prompt are guaranteed to print. As before, adding an extra `[]` on the end of `:=` query is a recommended idiom to update and then print; e.g.> `DT[,foo:=3L][]`.

## I've noticed that `base::cbind.data.frame` (and `base::rbind.data.frame`) appear to be changed by `data.table`. How is this possible? Why?

It is a temporary, last resort solution until we discover a better way to solve the problems listed below. Essentially, the issue is that `data.table` inherits from `data.frame`, _and_ `base::cbind` and `base::rbind` (uniquely) do their own S3 dispatch internally as documented by `?cbind`. The change is adding one `for` loop to the start of each function directly in `base`; _e.g._,
Expand Down

0 comments on commit 4a5c85d

Please sign in to comment.