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

[R-Forge #4996] provide a message when x[y,newcol:=my_ycol] does not create a new column #354

Closed
arunsrinivasan opened this issue Jun 8, 2014 · 3 comments

Comments

@arunsrinivasan
Copy link
Member

Submitted by: Frank Erickson; Assigned to: Arun ; R-Forge link

If I attempt to make a new column in x with

x[y,newcol:=my_ycol]

and fail to do so (because x[y] has no matches), I would like a message.


One idea: there is already a nice message (with verbose turned on) for

x[logi,newcol:=my_val]

where logi is FALSE:

No rows pass i clause so quitting := early with no changes made.


Another idea: there is already a nice error when assigning to NA after bad subsetting:

x <- data.table(a=1:2)
x[c(FALSE,FALSE,TRUE),newcol:=1]

which gives:

Error in [.data.table(x, c(FALSE, FALSE, TRUE), :=(newcol, 1)) :
i[1] is NA. Can't assign by reference to row 'NA'.

And a similar error message is given for x[3,newcol:=1].

@mattdowle
Copy link
Member

@arunsrinivasan Came across this one via #1150. Not sure why closed so reopening to come back to.

@mattdowle mattdowle reopened this Jun 19, 2015
@mattdowle mattdowle added this to the v1.9.8 milestone Jun 19, 2015
@jangorecki
Copy link
Member

duplicate of #759, IMO it should not be a message but a NA valued column added, as in SQL when using outer join and there is no matching values.

@arunsrinivasan
Copy link
Member Author

@mattdowle as Jan points out, this is a duplicate. I must have forgotten to add the issue at the time.

mattdowle added a commit that referenced this issue Sep 29, 2016
…Col==3] where DT is one row and someCol is NA, returns no rows for consistency with nrow>1 cases. +with=FALSE with := now warns. +nomatch with := now warns. +logical i no longer recycles unless length 1 or nrow. #1001 #1002 #759 #354 #166 and closes #1252.
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

3 participants