Janko Thyson
2012-Jun-28 09:40 UTC
[R] Feature request: 'file.path()' accepting an input vector
Dear list, I have a small feature request regarding the implementation of 'file.path()': It'd be great if 'file.path()' would allow to specify an input *vector* instead of solely rely on a specification via the three dot argument. AFAIU, currently it's only possible to "manually" specify each path component via the three dot argument: > file.path(letters[1], letters[2], letters[3]) [1] "a/b/c" Providing a vector object will result in the same vector being returned, instead of a slash separated scalar: > file.path(letters[1:3]) [1] "a" "b" "c" It'd be great if the last call would have this result: > file.path(letters[1:3]) [1] "a/b/c" If that's already possible, I'd appreciate a pointer. If not: thanks a lot for considering this, Best regards, Janko
Prof Brian Ripley
2012-Jun-28 10:10 UTC
[R] Feature request: 'file.path()' accepting an input vector
On 28/06/2012 10:40, Janko Thyson wrote:> Dear list, > > I have a small feature request regarding the implementation of > 'file.path()':Clearly you have not read where and how to make feature requests (R-devel list or Wishlist on bugs.r-project.org).> > It'd be great if 'file.path()' would allow to specify an input *vector* > instead of solely rely on a specification via the three dot argument. > > AFAIU, currently it's only possible to "manually" specify each path > component via the three dot argument: > > file.path(letters[1], letters[2], letters[3]) > [1] "a/b/c" > > Providing a vector object will result in the same vector being returned, > instead of a slash separated scalar: > > file.path(letters[1:3]) > [1] "a" "b" "c" > > It'd be great if the last call would have this result: > > file.path(letters[1:3]) > [1] "a/b/c" > > If that's already possible, I'd appreciate a pointer. If not: thanks a > lot for considering this,It's not going ever to be possible: it does what it is intended and documented to do with a single vector, and people rely on the existing behaviour. OTOH paste(x, collapse="/") does what you want (you could use .Platform$file.sep for maximal portability). Or you could use do.call(file.path, as.list(x))> > Best regards, > Janko-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Possibly Parallel Threads
- How can I write methods for 'as()'?
- Reset R's library to base packages only (remove all installed contributed packages)
- Bug or feature: using "ANY" as a generic field class (was: '[R] Is there a (virtual) class that all R objects inherit from?)
- Feature request: mixing `...` (three dots) with other formal arguments in S4 methods
- Feature request: mixing `...` (three dots) with other formal arguments in S4 methods