R/useRproj.R

Defines functions useRproj

Documented in useRproj

#' Add an .Rproj file based on a template
#'
#' This function creates an `<pkgName>.Rproj` file with standard options.
#'
#' @inheritParams addSSHremote
#' @inheritParams base::files
#'
#' @importFrom rstudioapi openProject
#'
#' @examplesIf interactive()
#' useRproj()
#'
#' @export
useRproj <- function(pkgDir = ".", overwrite = FALSE) {
    pkg_name <- devtools::as.package(pkgDir)[["package"]]
    template <- system.file(
        "resources", "template.Rproj", package = "BiocAddins", mustWork = TRUE
    )
    rproj_file <- file.path(pkgDir, paste0(pkg_name, ".Rproj"))
    if (!file.exists(rproj_file))
        file.copy(
            from = template,
            to = rproj_file,
            overwrite = overwrite
        )
    rstudioapi::openProject(path = rproj_file)
}
Bioconductor/BiocAddins documentation built on July 5, 2025, 3:21 a.m.