Open 1danjordan opened 7 years ago
Good idea. Here is some (incomplete) preliminary work: https://github.com/richfitz/pathr
Another advantage would be handling paths regardless of OS - escaping Windows paths or flipping them is driving me nuts on my work machine! 😒
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, orPath
could provide a factory method for parsing their outputs so we could still use them likelist.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!