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

haven now supports selective column and row reading #248

Closed
1 of 3 tasks
leeper opened this issue Nov 8, 2019 · 5 comments
Closed
1 of 3 tasks

haven now supports selective column and row reading #248

leeper opened this issue Nov 8, 2019 · 5 comments
Assignees
Milestone

Comments

@leeper
Copy link
Contributor

leeper commented Nov 8, 2019

Please specify whether your issue is about:

  • a possible bug
  • a question about package functionality
  • a suggested code or documentation change, improvement to the code, or feature request
@leeper leeper self-assigned this Nov 8, 2019
@mikmart
Copy link

mikmart commented Nov 24, 2019

One consequence of the haven changes that was just brought up in this Stack Overflow question is that col_select in haven's reader functions is a quoted argument and shouldn’t be evaluated early:

f <- tempfile(fileext = ".sas7bdat")
haven::write_sas(mtcars, f)

haven::read_sas(f, col_select = mpg)
#> # A tibble: 32 x 1
#>      mpg
#>    <dbl>
#>  1  21  
#>  2  21  
#>  3  22.8
#>  4  21.4
#>  5  18.7
#>  6  18.1
#>  7  14.3
#>  8  24.4
#>  9  22.8
#> 10  19.2
#> # ... with 22 more rows
rio::import(f, col_select = mpg)
#> Error in rio::import(f, col_select = mpg): object 'mpg' not found

@leeper
Copy link
Contributor Author

leeper commented Dec 17, 2019

Thanks. That's useful to know.

@leeper leeper added this to the v0.6 milestone Dec 19, 2019
@leeper leeper changed the title haven now supports selective column amd row reading haven now supports selective column and row reading Dec 24, 2019
bokov added a commit to bokov/rio that referenced this issue Jan 7, 2020
…in the case of '.dta' files. This is a draft PR, in the final PR, 'arg_reconcile()' will similarly be extended to all the other formats we use via 'haven'
@bokov
Copy link
Contributor

bokov commented Jan 7, 2020

col_select in haven's reader functions is a quoted argument and shouldn’t be evaluated early

Actually, both the haven functions and the dplyr::select() method to which their documentation refers permit quoted column names.

@mikmart
Copy link

mikmart commented Feb 9, 2020

@bokov yeah, what I meant was that when bare column names are passed, col_select needs to be evaluated in the appropriate context to avoid the "object not found" errors.

At the moment all ... args to import() are put in a list: https://github.com/leeper/rio/blob/ba74db92ecdb6d47b80c172359b58f60d388ba11/R/import.R#L129
That then forces evaluation on all of them.

@bokov
Copy link
Contributor

bokov commented Mar 8, 2021

We could just advise users to enclose the col_select argument in quotes or wrap it in quote() in the help file... would that address the problem?

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

No branches or pull requests

4 participants