bvarick / route_analysis

GNU General Public License v3.0
0 stars 1 forks source link

Using R Markdown and make #1

Closed syounkin closed 3 weeks ago

syounkin commented 3 weeks ago

Ben,

We like to use R markdown scripts and run them with make. I thought you might be interested in this style. I learned from Karl Broman.

Sam

bvarick commented 3 weeks ago

I am quite interested thanks for sharing that! I've used RMarkdown before to make web pages from the outputs of R scripts, but I haven't used make. Reading through your changes, it seems that

route_analysis: R/route_analysis.Rmd
    R -e 'library("rmarkdown"); old_path <- Sys.getenv("PATH"); Sys.setenv(PATH = paste(old_path, "/usr/local/bin", sep = ":")); rmarkdown::render(knit_root_dir = "~/route_analysis/", output_dir = "~/route_analysis/html", input = "./R/route_analysis.Rmd", output_file = "./html/route_analysis.html")'

would output the rendering to ~/route_analysis/html. Is that right? I have my directories structured so that the route_analysis directory is stored somewhere else, and I'd like the html output to go there. Can I change that to be ...knit_root_dir = "$PWD", output_dir = "$PWD/html"? Or something like that? Am I reading this right?

bvarick commented 3 weeks ago

I changed some things to work in my system:

Does this work for your workflow?

syounkin commented 3 weeks ago

I like storing input data outside the working directory on a secure server such as Box. A link to the server is used in place of a data subdirectory. This way the code can always refer to ./data/ without having to worry about differing pathnames across platform, user, etc. I did this with ln -s ~/data/Box/HOT/bvarick/data/ ./data. Note that I stopped tracking data/ and ignore the data link.

bvarick commented 3 weeks ago

I figured it out. Just had to change my RStudio settings.