Skip to content
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

Reading from multiple files AND make a column selection including the id column #197

Closed
atomman opened this issue Dec 27, 2019 · 1 comment

Comments

@atomman
Copy link

atomman commented Dec 27, 2019

Trying to read in multiple files and select a subset of the columns including the "id" column fails.

mt <- tibble::rownames_to_column(mtcars, "model")
purrr::iwalk(
  split(mt, mt$cyl),
  ~ vroom_write(.x, glue::glue("mtcars_{.y}.csv"), "\t")
)

files <- fs::dir_ls(glob = "mtcars*csv")
#> mtcars_4.csv mtcars_6.csv mtcars_8.csv
vroom(files, id = "path", col_select= c(mpg,cyl,disp, "path"))
Error in vroom_(file, delim = delim, col_names = col_names, col_types = col_types, : Evaluation error: Unknown column `path` Call `rlang::last_error()` to see a backtrace.
@jimhester
Copy link
Collaborator

Please try the development version of vroom, this is a duplicate of #110 and should be fixed in the devel version.

remotes::install_dev("vroom")

library(vroom)

mt <- tibble::rownames_to_column(mtcars, "model")
purrr::iwalk(
  split(mt, mt$cyl),
  ~ vroom_write(.x, glue::glue("mtcars_{.y}.csv"), "\t")
)

files <- fs::dir_ls(glob = "mtcars*csv")
vroom(files, id = "path", col_select= c(mpg,cyl,disp, "path"))
#> # A tibble: 32 x 4
#>      mpg   cyl  disp path        
#>    <dbl> <dbl> <dbl> <chr>       
#>  1  22.8     4 108   mtcars_4.csv
#>  2  24.4     4 147.  mtcars_4.csv
#>  3  22.8     4 141.  mtcars_4.csv
#>  4  32.4     4  78.7 mtcars_4.csv
#>  5  30.4     4  75.7 mtcars_4.csv
#>  6  33.9     4  71.1 mtcars_4.csv
#>  7  21.5     4 120.  mtcars_4.csv
#>  8  27.3     4  79   mtcars_4.csv
#>  9  26       4 120.  mtcars_4.csv
#> 10  30.4     4  95.1 mtcars_4.csv
#> # … with 22 more rows

Created on 2019-12-27 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants