[R] project path in Rmd

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Thu Apr 2 11:34:05 CEST 2020

On Thu, 2 Apr 2020 11:02:56 +0200
Ivan Calandra <calandra using rgzm.de> wrote:

> I do not know this ".." command (could you please show me how to use
> it in a relative path?), but it sounds like a good start.

Each '..' in the path moves you up one level in the directory tree.
Here I use '..' once to access the sibling of the current directory,
then verify my assumption using the absolute path:

getwd() == path.expand('~/archive')
# [1] TRUE

A related thing is using '.' to mean the *current* directory (i.e. the
value of getwd()). It is sometimes useful e.g. if you have a file named
'~' in your current directory and want to avoid expanding it to your
home directory.

> But it implies that I know in advance how many folders up the parent
> directory is.

Yes, I think that hardcoding some part of *within-project* directory
structure is unavoidable. But it shouldn't cause any troubles as long
as the project (analysis/{scripts,raw_data,derived_data}) is considered
as a whole.

Best regards,

More information about the R-help mailing list