We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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)
The text was updated successfully, but these errors were encountered:
Thanks, confirmed:
library(tibble) tib <- tibble(a = 1, b = 2) cols <- glue::glue("c{1:2}") tib[cols] <- "bar" #> Error in `vectbl_as_new_col_index()`: #> ! Can't assign to columns that don't exist. #> ✖ Columns `c1` and `c2` don't exist. #> Backtrace: #> ▆ #> 1. ├─base::`[<-`(`*tmp*`, cols, value = `<chr>`) #> 2. ├─tibble:::`[<-.tbl_df`(`*tmp*`, cols, value = `<chr>`) #> 3. │ └─tibble:::tbl_subassign(x, i, j, value, i_arg, j_arg, substitute(value)) #> 4. │ └─tibble:::vectbl_as_new_col_index(j, x, j_arg, names2(value), value_arg) #> 5. │ └─tibble:::vectbl_as_col_location(...) #> 6. │ ├─tibble:::subclass_col_index_errors(...) #> 7. │ │ └─base::withCallingHandlers(...) #> 8. │ └─vctrs::vec_as_location(j, n, names, call = call) #> 9. └─vctrs (local) `<fn>`() #> 10. └─vctrs:::stop_subscript_oob(...) #> 11. └─vctrs:::stop_subscript(...) #> 12. └─rlang::abort(...) tib[as.character(cols)] <- "bar" tib #> # A tibble: 1 × 4 #> a b c1 c2 #> <dbl> <dbl> <chr> <chr> #> 1 1 2 bar bar df <- data.frame(a = 1, b = 2) df[cols] <- "bar" df #> a b c1 c2 #> 1 1 2 bar bar
Created on 2022-12-04 with reprex v2.0.2
Sorry, something went wrong.
glue()
Successfully merging a pull request may close this issue.
Like #778, but with multiple columns. Again casting the return as a character seems to work ok.
Created on 2022-05-10 by the reprex package (v2.0.1)
The text was updated successfully, but these errors were encountered: