Skip to content

Referencing columns with [ ] fails when column names are created from glue #1150

@asadow

Description

@asadow

Like #778, but with multiple columns. Again casting the return as a character seems to work ok.

library(tibble)

tib <- tibble(a = 1, b = 2)
tib[glue::glue("c{1:2}")] <- "bar"
#> Error: Can't assign to columns that don't exist.
#> x Columns `c1` and `c2` don't exist.
tib[as.character(glue::glue("c{1:2}"))] <- "bar"

df <- data.frame(a = 1, b = 2)
df[glue::glue("c{1:2}")] <- "bar"

Created on 2022-05-10 by the reprex package (v2.0.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions