Skip to contents

While working on the same script both in a remote server and locally on your home computer, defining file paths can be unwieldy and may even require duplicate scripts–one for each location–that require maintenance in parallel. This function allows you to define whether you are working locally or not and specify the path to use in either case.

Usage

wd_loc(local = TRUE, local_path = getwd(), remote_path = NULL)

Arguments

local

(logical) Whether you are working locally or on a remote server

local_path

(character) File path to use if `local` is `TRUE` (defaults to `getwd()`)

remote_path

(character) File path to use if `local` is `FALSE`

Value

(character) Either the entry of `local_path` or `remote_path` depending on whether `local` is set as true or false

Examples

# Set two working directory paths to toggle between

# If you are working in your local computer, set `local` to "TRUE"
wd_loc(local = TRUE,
       local_path = file.path("local path"),
       remote_path = file.path("path on server"))
#> [1] "local path"
       
# If you are working in a remote server, set `local` to "FALSE"
wd_loc(local = FALSE,
       local_path = file.path("local path"),
       remote_path = file.path("path on server"))
#> [1] "path on server"