RStudio template project enable renv

I'm looking at create a template for package development, and wanted to create a custom template.
I reviewed:
https://rstudio.github.io/rstudio-extensions/rstudio_project_templates.html#overview

How do I enable renv and git, just call:
renv::init() and usethis::use_git()

and saw this post but no replies, and was wonder if this is the correct way?

Hi @shannon.lewis,

Sorry that my previous thread didn't get answered but I think we can figure this out together.

I'm guessing that avoiding the use of usethis is necessary for non-package projects, but it should probably work for package projects. In either case, git2r::init() will work to initialize a git repo regardless.

renv::init() should work without much issue, I think. Something like below should get you started. Let me know if you run into any issues.

# project.dcf
Title: Project Template Name
Subtitle: Some great description...
Binding: project_fun

Parameter: git
Widget: CheckboxInput
Label: Create a git repository

Parameter: renv
Widget: CheckboxInput
Label: Initialize a project-local library
project_fun <- function(path, ...) {
  dots <- list(...)
  dir.create(path)
  if (dots$git) git2r::init(path)
  if (dots$renv) renv::init(path)
}
1 Like

Thank you ....i'll give it a go and report back.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.