-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
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
Can pass quosure to col
arg in separate()
#360
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This fixes the linked issue and doesn't introduce any new bugs. But, when looking through this I realized library(tidyr, warn.conflicts = FALSE)
library(data.table, warn.conflicts = FALSE)
library(dtplyr)
dt <- data.table(x = c("a_a", "b_b", "c_c"))
df <- as.data.frame(dt)
df %>%
separate(1, into = c("left", "right"))
#> left right
#> 1 a a
#> 2 b b
#> 3 c c
dt %>%
separate(1, into = c("left", "right"))
#> Warning: Using `as.character()` on a quosure is deprecated as of rlang 0.3.0.
#> Please use `as_label()` or `as_name()` instead.
#> This warning is displayed once per session.
#> Source: local data table [3 x 2]
#> Call: copy(`_DT1`)[, `:=`(c("left", "right"), tstrsplit(~1, split = "[^[:alnum:]]+"))][,
#> .(left, right)]
#>
#> left right
#> <chr> <chr>
#> 1 1 1
#> 2 1 1
#> 3 1 1
#>
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results Created on 2022-06-17 by the reprex package (v2.0.1) |
@eutwt I ended up using |
@markfairbanks I think it should error on >1 column library(tidyr, warn.conflicts = FALSE)
library(data.table, warn.conflicts = FALSE)
devtools::load_all("/Users/mbp/Documents/GitHub/dtp")
#> ℹ Loading dtplyr
#> Warning: package 'dplyr' was built under R version 4.1.2
dt <- data.table(x = c("a_a", "b_b", "c_c"))[, y := x]
df <- as.data.frame(dt)
df %>%
separate(c(x, y), into = c("left", "right"))
#> Error in `pull_as_location2()`:
#> ! Must extract column with a single valid subscript.
#> ✖ Subscript `var` has size 2 but must be size 1.
dt %>%
separate(c(x, y), into = c("left", "right"))
#> Source: local data table [3 x 3]
#> Call: copy(`_DT1`)[, `:=`(c("left", "right"), tstrsplit(x, split = "[^[:alnum:]]+"))][,
#> .(y, left, right)]
#>
#> y left right
#> <chr> <chr> <chr>
#> 1 a_a a a
#> 2 b_b b b
#> 3 c_c c c
#>
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results Created on 2022-06-17 by the reprex package (v2.0.1) |
Closes #359