Re: [R] How to join path with arguments

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue, 19 Feb 2008 13:16:21 +0000 (GMT)

Please just use file.path(inputdir, filename).

Apart from being less error-prone, in R 2.7.0 it will be internal and so faster (and in case you wonder how paste could be too slow, it was in some of the package installation/checking computations).

On Tue, 19 Feb 2008, Henrique Dallazuanna wrote:

> Ops,
> paste(inputdir, filename, sep="") should be paste(inputdir, filename, sep="/")
>
> On 19/02/2008, Henrique Dallazuanna <wwwhsd_at_gmail.com> wrote:
>> Try this:
>>
>> name1 <- 'sample-plot'
>> filename <- sprintf("%s.png", name1)
>> inputdir <- '/path/to/dir'
>> paste(inputdir, filename, sep="")
>>
>>
>> On 19/02/2008, Hyunchul Kim <sundol313_at_naver.com> wrote:
>>> Hi, all
>>>
>>> How to format and join strings ?
>>> For example, like following short python examples.
>>>
>>> *********
>>> name1 = 'sample-plot'
>>> filename = '%s.png' % name1
>>>
>>> inputdir = '/path/to/dir'
>>> os.path.join(inputdir, filename)
>>>
>>> **********
>>>
>>> Best,
>>> Hyunchul Kim
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help_at_r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>> --
>> Henrique Dallazuanna
>> Curitiba-Paraná-Brasil
>> 25° 25' 40" S 49° 16' 22" O
>>
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
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


______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

Received on Tue 19 Feb 2008 - 13:19:50 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 19 Feb 2008 - 13:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive