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

write_*() doesn't invisibly return input dataframe #349

Closed
austensen opened this Issue Feb 16, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@austensen
Copy link
Contributor

austensen commented Feb 16, 2018

Unlike other tidyverse write_*() functions, it seems like haven doesn't invisibly return the input dataframe to allow for writing as part of a pipeline.

# devtools::install_github("tidyverse/haven", ref = "v0.2.1")

library(haven)

df <- write_dta(mtcars, "mtcars.dta")

print(df)
#> NULL
Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.4.3 (2017-11-30)
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  tz       America/New_York            
#>  date     2018-02-16
#> Packages -----------------------------------------------------------------
#>  package   * version    date       source                          
#>  backports   1.1.1      2017-09-25 CRAN (R 3.4.2)                  
#>  base      * 3.4.3      2017-12-07 local                           
#>  compiler    3.4.3      2017-12-07 local                           
#>  datasets  * 3.4.3      2017-12-07 local                           
#>  devtools    1.13.3     2017-08-02 CRAN (R 3.4.1)                  
#>  digest      0.6.12     2017-01-27 CRAN (R 3.4.0)                  
#>  evaluate    0.10.1     2017-06-24 CRAN (R 3.4.1)                  
#>  graphics  * 3.4.3      2017-12-07 local                           
#>  grDevices * 3.4.3      2017-12-07 local                           
#>  haven     * 0.2.1      2018-02-16 Github (tidyverse/haven@8ef6662)
#>  htmltools   0.3.6      2017-04-28 CRAN (R 3.4.0)                  
#>  knitr       1.17       2017-08-10 CRAN (R 3.4.1)                  
#>  magrittr    1.5        2014-11-22 CRAN (R 3.4.0)                  
#>  memoise     1.1.0      2017-04-21 CRAN (R 3.4.0)                  
#>  methods   * 3.4.3      2017-12-07 local                           
#>  Rcpp        0.12.15    2018-01-20 cran (@0.12.15)                 
#>  rmarkdown   1.7        2017-11-10 CRAN (R 3.4.2)                  
#>  rprojroot   1.2        2017-01-16 CRAN (R 3.4.0)                  
#>  stats     * 3.4.3      2017-12-07 local                           
#>  stringi     1.1.5      2017-04-07 CRAN (R 3.4.0)                  
#>  stringr     1.2.0      2017-02-18 CRAN (R 3.4.0)                  
#>  tools       3.4.3      2017-12-07 local                           
#>  utils     * 3.4.3      2017-12-07 local                           
#>  withr       2.1.0.9000 2017-12-04 Github (jimhester/withr@fe81c00)
#>  yaml        2.1.14     2016-11-12 CRAN (R 3.4.0)

It seems like this would just be a matter of adding invisible(data) at the end of each of the write_*() R functions, but I'm not completely sure about this since the actual writing is via Rcpp calls. If it is the case that that's all that needs to be added (along with updates to the docs and tests), I'd be happy to submit a pull request adding this if that would be helpful.

Here is an example for write_dta(). Is this all that would be needed?

write_dta <- function(data, path) {
  write_dta_(data, normalizePath(path, mustWork = FALSE))
  invisible(data)
}
@hadley

This comment has been minimized.

Copy link
Member

hadley commented Feb 18, 2018

A PR would be great, and that’s just the code that’s needed 😀

@lock

This comment has been minimized.

Copy link

lock bot commented Aug 19, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Aug 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.