Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data.table not printed when it should #939

Closed
jangorecki opened this issue Nov 9, 2014 · 7 comments
Closed

data.table not printed when it should #939

jangorecki opened this issue Nov 9, 2014 · 7 comments

Comments

@jangorecki
Copy link
Member

Following code will not print DT in the first attempt.

library(data.table)
library(jsonlite)
lot.dict.new <- setkeyv(setDT(fromJSON("https://api.hitbtc.com/api/1/public/symbols")[["symbols"]]),"symbol")[,c("step","lot","takeLiquidityRate","provideLiquidityRate") := lapply(.SD, as.numeric), .SDcols=c("step","lot","takeLiquidityRate","provideLiquidityRate")]
lot.dict.new # there is no print here
lot.dict.new # it works when trying for a second time

it is reproducible on my machine:

R version 3.1.2 (2014-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
data.table 1.9.5 as of 2014-11-02
@arunsrinivasan
Copy link
Member

@jangorecki this is explained in the first bug fix under README.

if (TRUE) DT[,LHS:=RHS] no longer prints, #869. Tests added. To get this to work we've had to live with one downside: 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][]. Thanks to Jureiss for reporting.

@jangorecki
Copy link
Member Author

ok, thanks, might be worth to note somewhere in the FAQ

@arunsrinivasan
Copy link
Member

@jangorecki, good point. Will keep this open until then.

@gsee
Copy link

gsee commented Nov 15, 2014

For me, having to wrap invisible around DT[, LHS:=RHS] in an if statement was less inconenient than having to add brackets in 300 functions in one of my packages so that they'll print like they have in the past. Just my 2 cents, and I realize other users may prefer the new behavior.

@arunsrinivasan arunsrinivasan added this to the v1.9.6 milestone Dec 4, 2014
@arunsrinivasan arunsrinivasan modified the milestones: v1.9.8, v1.9.6 Feb 14, 2015
@arunsrinivasan
Copy link
Member

Moved to 1.9.8

@franknarf1
Copy link
Contributor

Same with merge:

merge(data.table(a=1,b=2),data.table(a=1,d=2), by="a")
# prints nothing

(I'm assuming this is the same issue based on the title and its still being open.)

@malcook
Copy link

malcook commented Sep 1, 2016

I find this to be the case using data.table_1.9.6 in R 3.3.1 - but I can not yet characterize it sufficiently to warrant a new issue here. Just sayin'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants