ropensci / unconf17

Website for 2017 rOpenSci Unconf
http://unconf17.ropensci.org
64 stars 12 forks source link

Package to help working with filepaths #99

Open 1danjordan opened 7 years ago

1danjordan commented 7 years ago

Working with filepaths in R is a total pain in the ass, mainly because we treat them exclusively as character vectors. This means we're stuck parsing filepaths with messy regexes at best, and still no way of reliably building filepaths apart from string concatenation. There's also no way of building relative and absolute paths reliably.

I propose a package with a Path object that provides us structured filepaths and methods in a similar way to Ammonite's Path object in Scala. For some concrete examples of this, you can see Li Haoyi demonstrating it at minute 18 of his A Better Scala REPL talk.

This package could have implementations of list.files, list.dirs, getwd and so on, or Path could provide a factory method for parsing their outputs so we could still use them like list.files() %>% Path.

I believe the current state of filepaths is a real pain point, and think a solution like this would be a good direction, but am obviously open to discussing other solutions!

gaborcsardi commented 7 years ago

Good idea. Here is some (incomplete) preliminary work: https://github.com/richfitz/pathr

1danjordan commented 7 years ago

Another advantage would be handling paths regardless of OS - escaping Windows paths or flipping them is driving me nuts on my work machine! 😒