markfairbanks / tidytable

Tidy interface to 'data.table'
https://markfairbanks.github.io/tidytable/
Other
449 stars 33 forks source link

Check that is.data.table(DT) == TRUE #687

Closed nick-youngblut closed 1 year ago

nick-youngblut commented 1 year ago

I'm developing a package that includes tidytable. I have some package data:

F = 'data-raw/substrate-well.tsv'
substrate_well = read.table(F, sep='\t') 
usethis::use_data(substrate_well, overwrite = TRUE)

The function in my package:

get_substrate_well = function(){
  substrate_well %>%
    mutate.(Plate = as.numeric(gsub('PM*', '', Plate)))
}

When I run devtools::load_all(); get_substrate_well (), I get the following error:

Error in `:=`(Plate = as.numeric(gsub("PM*", "", Plate))) : 
Check that is.data.table(DT) == TRUE. Otherwise, := and `:=`(...) are defined for use in j, once only and in particular ways. See help(":=").

I have not idea why. I do not get the error if I use dplyr::mutate

markfairbanks commented 1 year ago

Can you see if the solution (option 1) in this comment fixes the issue? I’m guessing that’s the issue.

If that doesn’t work I’ll try to see what I can figure out this weekend.

nick-youngblut commented 1 year ago

Yeah, that seems to have fixed the issue. Thanks!

markfairbanks commented 1 year ago

Also FYI you can use mutate() (without the dot) in the latest version of tidytable. mutate.() still works too.

nick-youngblut commented 1 year ago

Also FYI you can use mutate() (without the dot) in the latest version of tidytable. mutate.() still works too.

Thanks for the tip! I like to include the . so that it is easy to distinguish tidytable code from dplyr code.