Skip to content

Update on join fails to find variable "immediate built" in i #7799

Description

@iagogv3

Let me show a minimal reprex as it is easier than describe and I am not sure why does it happen:

> library(data.table)
> irisdt<-as.data.table(iris)
> var="Sepal.Length"

Next works

> aux <- irisdt[, .(var = min(var)), env = list(var = var), by = Species]
> irisdt[, !c("Sepal.Length")][aux, on = "Species", SLM := var, env = list(var=paste0("i.", var))][]
     Sepal.Width Petal.Length Petal.Width   Species   SLM
           <num>        <num>       <num>    <fctr> <num>
  1:         3.5          1.4         0.2    setosa   4.3
  2:         3.0          1.4         0.2    setosa   4.3
  3:         3.2          1.3         0.2    setosa   4.3
  4:         3.1          1.5         0.2    setosa   4.3
  5:         3.6          1.4         0.2    setosa   4.3
 ---                                                     
146:         3.0          5.2         2.3 virginica   4.9
147:         2.5          5.0         1.9 virginica   4.9
148:         3.0          5.2         2.0 virginica   4.9
149:         3.4          5.4         2.3 virginica   4.9
150:         3.0          5.1         1.8 virginica   4.9

But if I do not use auxiliary variable aux and I include the summarised datatable in i, I get

> ## next, just to replicate my use case; irisdt2 is a data.table with a common variable to merge (Species)
>  irisdt2 <- irisdt[, !c("Sepal.Length")]
> irisdt2[irisdt[, .(var = min(var)), env = list(var = var), by = Species], on = "Species", SLM := var, env = list(var=paste0("i.", var))]
Error in .checkTypos(e, names_x) : 
  Object 'i.Sepal.Length' not found amongst [Sepal.Width, Petal.Length, Petal.Width, Species]

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions