Skip to content
Prev 383111 / 398502 Next

project path in Rmd

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

            
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:

setwd('~/temp')
setwd('../archive')
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.
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.