Commits


Romain Francois authored and François Saint-Jacques committed 4e6759c11cb
ARROW-5718: [R] auto splice data frames in record_batch() and table() elements of `...` that are unnamed in `record_batch(...)` or `table(...)` are automatically spliced: ``` r library(arrow, warn.conflicts = FALSE) library(tibble) df <- tibble(x = 1:10, y = letters[1:10]) ``` ``` r # auto splicing batch <- record_batch(df, z = 1:10) as_tibble(batch) #> # A tibble: 10 x 3 #> x y z #> <int> <chr> <int> #> 1 1 a 1 #> 2 2 b 2 #> 3 3 c 3 #> 4 4 d 4 #> 5 5 e 5 #> 6 6 f 6 #> 7 7 g 7 #> 8 8 h 8 #> 9 9 i 9 #> 10 10 j 10 # same as explicit splicing batch <- record_batch(!!!df, z = 1:10) as_tibble(batch) #> # A tibble: 10 x 3 #> x y z #> <int> <chr> <int> #> 1 1 a 1 #> 2 2 b 2 #> 3 3 c 3 #> 4 4 d 4 #> 5 5 e 5 #> 6 6 f 6 #> 7 7 g 7 #> 8 8 h 8 #> 9 9 i 9 #> 10 10 j 10 ``` ``` r # auto splicing tab <- table(df, z = 1:10) as_tibble(tab) #> # A tibble: 10 x 3 #> x y z #> <int> <chr> <int> #> 1 1 a 1 #> 2 2 b 2 #> 3 3 c 3 #> 4 4 d 4 #> 5 5 e 5 #> 6 6 f 6 #> 7 7 g 7 #> 8 8 h 8 #> 9 9 i 9 #> 10 10 j 10 # same as explicit splicing tab <- table(!!!df, z = 1:10) as_tibble(tab) #> # A tibble: 10 x 3 #> x y z #> <int> <chr> <int> #> 1 1 a 1 #> 2 2 b 2 #> 3 3 c 3 #> 4 4 d 4 #> 5 5 e 5 #> 6 6 f 6 #> 7 7 g 7 #> 8 8 h 8 #> 9 9 i 9 #> 10 10 j 10 ``` In particular, this gives us back `record_batch(<data.frame>)` and `table(<data.frame>)` : ``` r library(arrow, warn.conflicts = FALSE) library(tibble) df <- tibble(x = 1:10, y = letters[1:10]) record_batch(df) #> arrow::RecordBatch table(df) #> arrow::Table ``` Author: Romain Francois <romain@rstudio.com> Closes #4704 from romainfrancois/ARROW-5718/df_auto_splice and squashes the following commits: 79a70412c <Romain Francois> more tests about auto splicingh in record_batch() 28bc470c9 <Romain Francois> + comment 61902ab7c <Romain Francois> table() auto splicing 0a4892c21 <Romain Francois> record_batch() auto splicing of data frames 5eabd202a <Romain Francois> trim redundant code