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

issues with invisible functions in j-expression #1733

Open
eantonya opened this issue Jun 7, 2016 · 3 comments
Open

issues with invisible functions in j-expression #1733

eantonya opened this issue Jun 7, 2016 · 3 comments
Labels

Comments

@eantonya
Copy link
Contributor

eantonya commented Jun 7, 2016

dt = data.table(a = 1:5)

# all is well
boxplot(dt$a)

# lots of errors
dt[, boxplot(a)]
#Error in data.table(stats = c(1, 2, 3, 4, 5), n = 5, conf = c(1.58680503822013,  : 
#  Item 4 has no length. Provide at least one item (such as NA, NA_integer_ etc) to be repeated to #match the 5 rows in the longest column. Or, all columns can be 0 length, for insert()ing rows into.
#In addition: Warning message:
#In data.table(stats = c(1, 2, 3, 4, 5), n = 5, conf = c(1.58680503822013,  :
#  Item 3 is of size 2 but maximum size is 5 (recycled leaving remainder of 1 items)

Related to #482. Iirc it used to plot and output all the stuff you get if you do (boxplot(dt$a)), but now it's not working at all.

@eantonya eantonya added the bug label Jun 7, 2016
@franknarf1
Copy link
Contributor

This makes sense to me since the end result of a j expression is coerced to a data.table.

What I find weird is that dt[, hist(a)] from #1471 works without error, even though it's another case of a list that doesn't coerce to data.table nicely. I don't know the internal bit of code that handles this coercion, but it seems to fail in the latter case because as.data.table.histogram is not a thing, while as.data.table.list is (and boxplot just gives a list).

Personally, I would like to see an option to turn off the coercion (with j returned raw or, when by= is present, as a list column, as in dt[, .(.(boxplot(a))), by=rep(1,5)]).

@jangorecki
Copy link
Member

jangorecki commented Jun 13, 2016

@franknarf1 drop=TRUE could be used for that, where drop=FALSE would force to return data.table by adding additional setDT(list(j)) if j is not a data.table. I've proposed it in another issue where I would benefit from drop=FALSE.

@jangorecki
Copy link
Member

Ultimate solution would be to detect visibility of results in j and cascade it down. For now the good alternatives are using DT[,as.null(j)] -> nul or I() function instead of as.null. See related issue #4326.

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

No branches or pull requests

3 participants