jennybc / here_here

I love the here package. Here's why.
312 stars 30 forks source link

Question regarding best practice #5

Closed statquant closed 6 years ago

statquant commented 6 years ago

Hello, thank you very much for letting us use the here package. I heard many good things about it so I tried to use it myself. I think I like the here idea, but (shame) I am not sure I understand it correctly, or how it fits my current use case. Say I have a tree like

my_root_dir/         
|-- .here            
|-- data             
|   |-- today        
|   |-- tomo         
|   `-- yesterday    
|-- log              
`-- my_script.rscript
`-- my_logic.r

I want to execute the my_script.rscript (a she-bang script that leverage docopt or optparse) from anywhere and execute some logic in my_logic.r that would leverage the here package to do stuff in all sub-directories. When I do /a/b/c/d/my_root_dir/my_script.rscript --someoption the here() logic is likely to place my in the /a (it does when I try)

Right now I do (please do not kill me)

if(!interactive()) setwd(dirname(getopt:::get_Rscript_filename()))
library(here)

which seems very paradoxical...

Am I missing something ? Is it considered edge case because of interactive() ?

Kind regards

statquant commented 6 years ago

I realized there is in ?here Details

This package is intended for interactive use only. Use rprojroot::has_file() or the other functions in the rprojroot package for more control, or for package development.