Skip to content

Instantly share code, notes, and snippets.

@geotheory
Created June 24, 2019 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geotheory/bf27a813929d0622a1acbfc8c2e93972 to your computer and use it in GitHub Desktop.
Save geotheory/bf27a813929d0622a1acbfc8c2e93972 to your computer and use it in GitHub Desktop.
# setup
unlink('~/Downloads/here-test/', recursive = TRUE)
getwd()
#> [1] "/private/var/folders/_3/b8whcf8d1bb8w_lr2rrscb5m0000gp/T/RtmpAnPCwY/reprex5e3e200cebe1"
proj_path = '~/Downloads/here-test'
dir.create(proj_path)
setwd(proj_path)
here::set_here()
#> Created file .here in /Users/robinedwards/Downloads/here-test
list.files(all.files = TRUE)
#> [1] "."     ".."    ".here"
writeLines(text = "require(here); dr_here()", con = 'test.R')

# test
setwd('~')
system('Rscript ~/Downloads/here-test/test.R')

standard output and standard error

Loading required package: here
here() starts at /Users/robinedwards
here() starts at /Users/robinedwards, because none of the following criteria apply for this directory or any of its parents:
- contains a file `.here`
- contains a file matching `[.]Rproj$` with contents matching `^Version: ` in the first line
- contains a file `DESCRIPTION` with contents matching `^Package: `
- contains a file `remake.yml`
- contains a file `.projectile`
- contains a directory `.git`
- contains a file `.git` with contents matching `^gitdir: `
- contains a directory `.svn`
Use set_here() to create a `.here` file
[WARNING] Could not parse YAML metadata at line 13 column 1: :7:21: Unexpected '
  '
Warning message:
In in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE,  :
  You changed the working directory to /Users/robinedwards (probably via setwd()). It will be restored to /private/var/folders/_3/b8whcf8d1bb8w_lr2rrscb5m0000gp/T/RtmpAnPCwY/reprex5e3e200cebe1. See the Note section in ?knitr::knit

Created on 2019-06-24 by the reprex package (v0.2.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment