Closed markfairbanks closed 2 years ago
pacman::p_load(tidytable, tidyverse) df <- tidytable(x = c("a", "a.b", "a.b", NA), y = 1:4) df %>% separate.(x, into = c("c1", "c2"), remove = FALSE) #> # A tidytable: 4 × 4 #> x y c1 c2 #> <chr> <int> <chr> <chr> #> 1 a 1 a <NA> #> 2 a.b 2 a b #> 3 a.b 3 a b #> 4 <NA> 4 <NA> <NA> df %>% tidyr::separate(x, into = c("c1", "c2"), remove = FALSE) #> Warning: Expected 2 pieces. Missing pieces filled with `NA` in 1 rows [1]. #> # A tidytable: 4 × 4 #> x c1 c2 y #> <chr> <chr> <chr> <int> #> 1 a a <NA> 1 #> 2 a.b a b 2 #> 3 a.b a b 3 #> 4 <NA> <NA> <NA> 4
As I think about this - if the user needs to move the columns they can do that with relocate.().
relocate.()