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

Class of returned object for path_tidy/new_fs_path #91

MirzaCengic opened this Issue Mar 20, 2018 · 1 comment


None yet
2 participants
Copy link

MirzaCengic commented Mar 20, 2018


I was recently trying to switch my workflow from base functions to fs functions, and it works quite well, however some functions will fail when the value of fs function is given to them since they do not use method for the fs_path class. Here is an example where I store intermediate files as temporary ones in a raster workflow.

tempfile_base <- tempfile(fileext = ".tif") 
[1] "character"
tempfile_fs <- fs::file_temp(ext = ".tif") 
[1] "fs_path"   "character"

r <- raster::raster(volcano)
raster::writeRaster(r, tempfile_base) # Works fine
raster::writeRaster(r, tempfile_fs)
# > Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘writeRaster’ for signature ‘"RasterLayer", "fs_path"’

I'm not sure if this is an actual issue or not, since it is easily solved by wrapping it in as.character() function, so this is more like a feedback for the package API. I assume that there is a good reason for having the returned value as fs_path class (colors/encoding?!?), maybe a solution would be to have return as.character argument (would this break the consistency in returning the UTF path?!?).

Cheers and thanks for the work on this package!

@jimhester jimhester closed this in a621788 Mar 20, 2018


This comment has been minimized.

Copy link

jimhester commented Mar 20, 2018

Thanks, this was an issue with S4 dispatch and should now be fixed

raster::writeRaster(raster::raster(volcano), fs::file_temp())
#> class       : RasterLayer 
#> dimensions  : 87, 61, 5307  (nrow, ncol, ncell)
#> resolution  : 0.01639344, 0.01149425  (x, y)
#> extent      : 0, 1, 0, 1  (xmin, xmax, ymin, ymax)
#> coord. ref. : NA 
#> data source : /private/var/folders/dt/r5s12t392tb5sk181j3gs4zw0000gn/T/RtmpFjgQwr/file1af473ce14e9.grd 
#> names       : layer 
#> values      : 94, 195  (min, max)

Created on 2018-03-20 by the reprex package (v0.2.0).

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