CIDA-CSPH / CIDAtools

Project and coding tools for the Center for Innovative Design and Analysis (CIDA)
https://cida-csph.github.io/CIDAtools/
9 stars 4 forks source link

Set and retrieve project location with new functions #11

Closed rpomponio closed 2 years ago

rpomponio commented 2 years ago

Summary of changes made in this commit

I added a parameter-value pair to Data.dcf in new projects to track the project location:

ProjectName: 
PI: 
analyst: 
location: BRANCHES/Pulmonary/My_Project

For projects that pre-date this fix, location can be set with:

CIDATools::SetProjectData("location", "BRANCHES/Pulmonary/My_Project")

And the function will automatically clean-up the location text provided (for example, if it ends in a slash or includes any text before BRANCHES).

To obtain the location of a particular file within the project, e.g. read a dataset:

df <- read.csv(CIDATools::ProjectLocation("DataRaw/my_data.csv”))

This will throw an error if project location is not defined in Data.dcf.

It will return a warning if the file does not exist due to: (1) the drive is not mounted or (2) there is a mis-spelling.

petersonR commented 2 years ago

Could you update the documentation via roxygen and see if it fixes the CMD-checks? e.g. run

devtools::document()

to update the man/*.Rd files based on your new documentation in the comments.

rpomponio commented 1 year ago

This does not seem to work if sourcing a script from within an .rmd file, for example, in a report:

source(here::here("Code/prelim_analysis.R"))

Might be related to how the here package works.