dfe-analytical-services / dfeR

Common R tasks in the Department for Education (DfE)
https://dfe-analytical-services.github.io/dfeR/
GNU General Public License v3.0
9 stars 2 forks source link

Pre-populated project template #70

Open JT-39 opened 4 weeks ago

JT-39 commented 4 weeks ago

Problem

Projects are at the heart of everything we code in R. I often find myself doing the same familiar steps when initialising an empty project, such as creating a .gitignore, including {renv}, adding an R/ and so on...

Context

It would be good to have a feature that allows pre-populates your project with the files, folders and structure you always spend time setting up at the start. This will also enforce a more consistent directory structure, as well as push best practice. The default to be included could be, a populated .gitignore, initialised {renv}, {testthat} workflow and QA folders, a README.md and other pre-populated files such as a guide to load data into R using a SQL connection (using {dfeR}).

Solution

A function that will create a new pre-populated project with essential files and folders (as outlined above). Use a .dcf file to also give the option to create this project template using the GUI method in R (by clicking "New Project" in the top right hand corner of the RStudio interface). Flexibility over the directory structure would be a good addition, as the files and folders required for projects can vary quite significantly (this can be done by adding optional parameters/widgets). For example, projects where the purpose is to build a publication pipeline Vs an ad-hoc exploratory analysis.

Alternatives

Other packages do offer this functionality already such as {usethis}, however these are not bespoke for analysts (nor DfE). Using the current method of creating a new project from scratch each time and encouraging people to use a particular folder structure could also work but is vulnerable to the issues described above and potential for deviation from good practice.

JT-39 commented 4 weeks ago

An additional function (suggested by @rmbielby) would be to automate the creation of an accompanying QA file for analysis scripts. The vision is for this to behave something similar to usethis::use_test("filename.R"), which creates a test file for the script defined.

JT-39 commented 3 weeks ago

Add {renv} to the package project and incrementing package version.

JT-39 commented 3 weeks ago

Could have an option that includes the necessary files for deploying to Posit Connect. For example, azure-pipelines.yml, config.yml, and more.

Additionally, git-hooks and other git management tools?

JT-39 commented 3 weeks ago

Add {renv} to the package project and incrementing package version.

Issue with this at the moment... when using {renv} the {covr} package fails. I am not sure why and have opened and issue on the package github repo.