Skip to content

Subassignment with a symbol doesn't work #893

@DavisVaughan

Description

@DavisVaughan

It does work for data frames though, so I figure we should be consistent.

Found here:
https://community.rstudio.com/t/unquoting-issue-in-purrr-map-df-function/106676/2

library(tibble)
library(rlang)

df <- data.frame(x = 1)
tbl <- tibble(x = 1)

x_sym <- sym("x")
x_chr <- "x"

df[[x_chr]] <- 2
tbl[[x_chr]] <- 2

# Can subset-assign with a symbol for data frames
df[[x_sym]] <- 2

# Can't subset-assign with a symbol for tibbles
tbl[[x_sym]] <- 2
#> Error: Can't use character names to index an unnamed vector.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions