Skip to content

transmute() on the same variable produces duplicate columns #249

Description

@mgirlich
library(dplyr, warn.conflicts = FALSE)
library(dtplyr)
# devtools::load_all("~/GitHub/dtplyr/")

dt <- lazy_dt(tibble(x = 1, y = 2), "DT")
dt %>% 
  transmute(x = x * 2, y = x + 2, x = y * 4)
#> Source: local data table [1 x 3]
#> Call:   DT[, {
#>     x <- x * 2
#>     y <- x + 2
#>     x <- y * 4
#>     .(x = x, y = y, x = x)
#> }]
#> 
#>       x     y     x
#>   <dbl> <dbl> <dbl>
#> 1    16     4    16
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results

dt %>% 
  as_tibble() %>% 
  transmute(x = x * 2, y = x + 2, x = y * 4)
#> # A tibble: 1 x 2
#>       x     y
#>   <dbl> <dbl>
#> 1    16     4

Created on 2021-05-19 by the reprex package (v2.0.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions