-
Notifications
You must be signed in to change notification settings - Fork 991
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
DT assign by ref not accept list col as RHS, error msg misleading #950
Comments
You should do: DT[.("a"),f:=list(list(function(x) x^3))] The first |
Of course, haven't tried it, sorry for bothering. Maybe improve error message to prevent same question in future(?). |
I encountered the same problem... and solved it by the solution here. Error message indeed for me does not provide clear explanation for the problem. |
@genwei007 How about including a gentle reminder:
Explaining it concisely and generally is a bit tough... we could also point to an FAQ/vignette about creating list columns? |
Thanks for answering. Sorry I am not quite familiar with data.table yet. I have tried using list(), but never think of using list(list()). It may be a point? |
Have you read the intro vignette? https://cloud.r-project.org/web/packages/data.table/vignettes/datatable-intro.html in particular around:
If this section is still confusing to you, please let us know. we're in the process of updating that vignette a bit (#2973) and would love your feedback! |
Not sure if this is an option, but how about (I use |
@franknarf1 I like it, but most often my usage looks like |
@MichaelChirico Browsing my code, I only use list columns for tables and always use a
This table wrangling is done in a wrapper for my main project code which has a "spec" that each csv is tested against on read and write (using vetr to make sure that every column meets basic rules like no NAs, formatting). So, against my suggestion: it's a pretty narrow use-case and not even in my main code; and in many cases you could do |
Perhaps a related case on SO: Error when trying to store list in data.table of length 1 |
Checked on the current latest DT version.
Take the two cols DT where second is list of functions:
Expected results would be to update by reference the
f
column in DT for rowid=="a"
.Error states that RHS is not a list which is not true. It does not update DT.
sessionInfo()
The text was updated successfully, but these errors were encountered: