{"id":14067988,"url":"https://github.com/bcgov/bcgovr","last_synced_at":"2025-07-30T02:32:40.031Z","repository":{"id":46515469,"uuid":"97760834","full_name":"bcgov/bcgovr","owner":"bcgov","description":"An R package to automate set up and sharing of R projects in bcgov GitHub following bcgov guidelines","archived":false,"fork":false,"pushed_at":"2024-09-24T02:17:22.000Z","size":9110,"stargazers_count":34,"open_issues_count":10,"forks_count":5,"subscribers_count":15,"default_branch":"main","last_synced_at":"2024-12-16T17:14:01.002Z","etag":null,"topics":["citz","env","r","r-package","rstats"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bcgov.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-19T21:00:51.000Z","updated_at":"2024-09-24T02:16:59.000Z","dependencies_parsed_at":"2024-09-16T01:16:56.052Z","dependency_job_id":null,"html_url":"https://github.com/bcgov/bcgovr","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/bcgov/bcgovr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcgov%2Fbcgovr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcgov%2Fbcgovr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcgov%2Fbcgovr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcgov%2Fbcgovr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcgov","download_url":"https://codeload.github.com/bcgov/bcgovr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcgov%2Fbcgovr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267798625,"owners_count":24145727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["citz","env","r","r-package","rstats"],"created_at":"2024-08-13T07:05:53.082Z","updated_at":"2025-07-30T02:32:39.499Z","avatar_url":"https://github.com/bcgov.png","language":"R","readme":"---\noutput:\n  github_document:\n    html_preview: true\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit README.Rmd (this file) --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"tools/readme/\"\n)\n\n```\n\n# bcgovr \u003cimg src=\"tools/readme/logo.png\" align=\"right\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![img](https://img.shields.io/badge/Lifecycle-Stable-97ca00)](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md)\n[![R-CMD-check](https://github.com/bcgov/bcgovr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/bcgov/bcgovr/actions/workflows/R-CMD-check.yaml)\n\n\u003c!-- badges: end --\u003e\n\n\n## Overview\n\nAn [R](http://r-project.org) package to automate set up and sharing of R projects in [bcgov GitHub](https://github.com/bcgov) following [bcgov guidelines](https://github.com/bcgov/BC-Policy-Framework-For-GitHub).\n\nAll B.C. Government employees are responsible for determining whether bcgov R source code can be shared on [bcgov GitHub](https://github.com/bcgov) and for following the [BC-Policy-Framework-For-GitHub](https://github.com/bcgov/BC-Policy-Framework-For-GitHub).\n\nYou will need to ensure that [Git](https://git-scm.com/) is installed on your computer. To add your project to bcgov GitHub users need to have a GitHub account _and_ be a [member of the bcgov GitHub organisation](https://github.com/bcgov/BC-Policy-Framework-For-GitHub/blob/master/BC-Gov-Org-HowTo/Cheatsheet.md). \n\n## Features\n\n### Functions\n\n`create_bcgov_project()` \u0026 `create_bcgov_package()` Create a new\u0026mdash;or populate an existing\u0026mdash;R project or R package with folders \u0026 files that encourage best practice in scientific computing _and_ with files that ensure the project meets [bcgov GitHub requirements](https://github.com/bcgov/BC-Policy-Framework-For-GitHub/blob/master/BC-Gov-Org-HowTo/Cheatsheet.md).\n\n`use_bcgov_git()` Initialise [Git](https://git-scm.com/) version control for an R project _and_ add files that ensure the project meets [bcgov GitHub requirements](https://github.com/bcgov/BC-Policy-Framework-For-GitHub/blob/master/BC-Gov-Org-HowTo/Cheatsheet.md).\n\n`use_bcgov_github()` Open a [bcgov GitHub repository](https://github.com/bcgov) and synchronise with an existing local R project _and_ add files that ensure the project meets [bcgov GitHub requirements](https://github.com/bcgov/BC-Policy-Framework-For-GitHub/blob/master/BC-Gov-Org-HowTo/Cheatsheet.md). `use_bcgov_github()` requires that your project already be a Git repository. Use `use_bcgov_git()` to initialise a Git repository.\n\n`create_from_bcgov_github()`  Clone a [bcgov GitHub repository](https://github.com/bcgov) _and_ add files that ensure the project meets [bcgov GitHub requirements](https://github.com/bcgov/BC-Policy-Framework-For-GitHub/blob/master/BC-Gov-Org-HowTo/Cheatsheet.md).\n\n`use_bcgov_req()` Add files to a new or existing R project to meet [bcgov GitHub requirements](https://github.com/bcgov/BC-Policy-Framework-For-GitHub/blob/master/BC-Gov-Org-HowTo/Cheatsheet.md). You can also add the [bcgov required files](https://github.com/bcgov/BC-Policy-Framework-For-GitHub/blob/master/BC-Gov-Org-HowTo/Cheatsheet.md) individually using `use_bcgov_contributing()`, `use_bcgov_licence()`, `use_bcgov_readme()`, `use_bcgov_readme_rmd()`, `use_bcgov_code_of_conduct()`.\n\n\n### RStudio bcgovr Project \u0026 Package Templates\n\nThe `create_bcgov_project()` or `create_bcgov_package()` and `use_bcgov_git` functions can be used simultaneously through the *bcgovr Project \u0026 Package* templates in the [RStudio](https://www.rstudio.com/) New Project dialogue box. The dialogue box allows a user to create a new R project or package with the option to select and individualise the required bcgov GitHub files and initialise Git version control.\n\n\n### RStudio Addins\n\nThe `bcgovr` package installs a set of [RStudio Addins](https://rstudio.github.io/rstudioaddins/):\n\n(i) Insert the [boiler-plate Apache 2.0 license header](https://github.com/bcgov/BC-Policy-Framework-For-GitHub/blob/master/BC-Open-Source-Development-Employee-Guide/Licenses.md) into the comments header of a source file (uses `insert_bcgov_apache_header()`).\n(ii) Insert the [boiler-plate Creative Commons Attribution 4.0 International License header](https://github.com/bcgov/BC-Policy-Framework-For-GitHub/blob/master/BC-Open-Source-Development-Employee-Guide/Licenses.md) into the comments header of a source file (uses `insert_bcgov_cc_header()`).\n(iii) Insert a [bcgov project lifecycle badge](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md) into an .Rmd or .md file to indicate the current state of a project (uses `insert_bcgov_lifecycle_badge()`).\n\n\n## Installation \n\nYou can install `bcgovr` directly from this GitHub repository. To do so, you will need the [remotes](https://cran.r-project.org/package=remotes) package:\n\n```{r, eval=FALSE}\ninstall.packages(\"remotes\")\n```\n\nNext, install and load the `bcgovr` package using `remotes::install_github()`:\n\n```{r, eval=FALSE}\nremotes::install_github(\"bcgov/bcgovr\")\nlibrary(bcgovr)\n```\n\n`r emo::ji(\"tada\")` The authors of `bcgovr` acknowledge and thank the authors of the [`usethis`](https://cran.r-project.org/package=usethis) R package\u0026mdash;`bcgovr` uses `usethis` _a lot_. And by a lot, we mean _every_ `bcgovr` function uses `usethis` under the hood `r emo::ji(\"oncoming_automobile\")`.\n\n\n## Usage\n\n### I WANT TO...\n\n\u003cdetails\u003e\u003csummary\u003e\u003cstrong\u003eCreate a new bcgov R project or package with a 'ready-to-go' folder \u0026 file structure\u003c/strong\u003e\u003c/summary\u003e\n\n\u003cbr /\u003e\n\nCreate and open\u0026mdash;or populate\u0026mdash;a local R project using `bcgovr::create_bcgov_project()`. Be sure to either specify your local directory using the `path` argument, or `setwd(\"C:/my-new-project\")` before running `create_bcgov_project()`. The template `bcgovr` folders and files and required bcgov GitHub files will be created in the new directory. For using different project templates, see the [Options](#options) section below. Type `?create_bcgov_project` in the R console for help.\n\n```{r, eval = FALSE}\ncreate_bcgov_project(path = \"C:/my-new-project\", coc_email = \"my.email@gov.bc.ca\") \n```\n\n```\nC:/my-new-project\n├── 01_load.R\n├── 02_clean.R\n├── 03_analysis.R\n├── 04_output.R\n├── CODE_OF_CONDUCT.md\n├── CONTRIBUTING.md\n├── LICENSE\n├── R\n├── README.Rmd\n├── data\n├── my-new-project.Rproj\n├── out\n└── run_all.R\n```\n\n\nThe `create_bcgov_package()` function is used the same way as `create_bcgov_project()` but will create all the folders \u0026 files to get started on creating an R package. Type `?create_bcgov_package` in the R console for help. The [R packages](http://r-pkgs.had.co.nz/) book by Hadley Wickham is a very useful resource if you are looking to create R packages.\n\n```{r, eval = FALSE}\ncreate_bcgov_package(path = \"C:/mynewrpackage\", coc_email = \"my.email@gov.bc.ca\") \n```\n\n```\nC:/mynewrpackage\n├── CODE_OF_CONDUCT.md\n├── CONTRIBUTING.md\n├── DESCRIPTION\n├── LICENSE\n├── NAMESPACE\n├── NEWS.md\n├── R\n├── README.Rmd\n├── man\n├── mynewrpackage.Rproj\n└── vignettes\n    └── mynewrpackage.Rmd\n```\n\nUsers can also use the *bcgovr Project \u0026 Package* templates in the [RStudio](https://www.rstudio.com/) New Project dialogue box to create a new R project or package. The dialogue box provides the option to select and individualise the required bcgov GitHub files and initialise Git version control.\n\n```{r echo=FALSE, out.width = \"30%\"}\nknitr::include_graphics(\"tools/readme/proj_template1.png\") \nknitr::include_graphics(\"tools/readme/proj_template2.png\") \nknitr::include_graphics(\"tools/readme/proj_template3.png\") \n```\n\n\u003cbr /\u003e\n\n\u003c/details\u003e\n\n\n\n\u003cdetails\u003e\u003csummary\u003e\u003cstrong\u003eInitialise Git version control for my R project (\u003ci\u003ewithout\u003c/i\u003e GitHub)\u003c/strong\u003e\u003c/summary\u003e\n\n\u003cbr /\u003e\n\nPut your local R project under version control by initialising a [Git](https://git-scm.com/) repository using `use_bcgov_git()`\u0026mdash;this automatically completes staging and committing of the initial folders \u0026 files inside the project. The `use_bcgov_git()` function also ensures the project has the required bcgov GitHub files. Type `?use_bcgov_git` in the R console for help.\n\n```{r, eval = FALSE}\nuse_bcgov_git(coc_email = \"my.email@gov.bc.ca\") \n```\n\n\u003cbr /\u003e\n\n\u003c/details\u003e\n\n\n\n\u003cdetails\u003e\u003csummary\u003e\u003cstrong\u003eOpen a bcgov GitHub repository and synchronise with my R project\u003c/strong\u003e\u003c/summary\u003e\n\n\u003cbr /\u003e\n\nShare your R project on [bcgov GitHub](https://github.com/bcgov) using `use_bcgov_github()`. This requires that your project already be a Git repository\u0026mdash;use `use_bcgov_git()` to initialise a Git repository if necessary. The `use_bcgov_github()` function creates a repository on bcgov GitHub and adds and synchronises your local project with the newly created bcgov GitHub origin. The `use_bcgov_github()` function also ensures the project has the required bcgov GitHub files. Type `?use_bcgov_github` in the R console for help.\n\n```{r, eval = FALSE}\nuse_bcgov_github(organisation = \"bcgov\", coc_email = \"my.email@gov.bc.ca\") \n```\n\n\u003cbr /\u003e\n\n\u003c/details\u003e\n\n\n\n\u003cdetails\u003e\u003csummary\u003e\u003cstrong\u003eClone and contribute to an existing bcgov GitHub repository\u003c/strong\u003e\u003c/summary\u003e\n\n\u003cbr /\u003e\n\nCreate a new local Git repository with a project or repository cloned from bcgov GitHub using `create_from_bcgov_github()`. The `create_from_bcgov_github()` function also ensures the project has the required bcgov GitHub files. Type `?create_from_bcgov_github` in the R console for help.\n\n```{r, eval = FALSE}\ncreate_from_bcgov_github(repo = \"bcgov/bcgovr\", destdir = \"C:/my_directory\") \n```\n\n\u003cbr /\u003e\n\n\u003c/details\u003e\n\n\n\n\u003cdetails\u003e\u003csummary\u003e\u003cstrong\u003eAdd all or some of the required bcgov GitHub files to my R project\u003c/strong\u003e\u003c/summary\u003e\n\n\u003cbr /\u003e\n\nAdd the [required bcgov GitHub](https://github.com/bcgov/BC-Policy-Framework-For-GitHub/blob/master/BC-Gov-Org-HowTo/Cheatsheet.md) files\u0026mdash;a LICENCE, a README, a CODE OF CONDUCT and a CONTRIBUTING file\u0026mdash;to any new or existing bcgov R project or package using `use_bcgov_req()`. Type `?use_bcgov_req` in the R console for help.\n\nYou can use the `licence`, `coc_email` \u0026 `rmarkdown` arguments to change the default Apache 2.0 License, add your contact details to the Code of Conduct, or decline a README.Rmd file\u0026mdash;maybe you only want a README.md for the project?\n\n```{r, eval=FALSE}\nuse_bcgov_req(licence = \"cc-by\", rmarkdown = FALSE, coc_email = \"my.email@gov.bc.ca\")\n```\n\nYou can also add the individual required files as needed using:\n\n```{r, eval=FALSE}\nuse_bcgov_licence()\nuse_bcgov_readme()\nuse_bcgov_contributing()\nuse_bcgov_code_of_conduct(coc_email = \"my.email@gov.bc.ca\")\n```\n\n\u003cbr /\u003e\n\n\u003c/details\u003e\n\n\n\n\u003cdetails\u003e\u003csummary\u003e\u003cstrong\u003eInsert a licence header into my source file\u003c/strong\u003e\u003c/summary\u003e\n\n\u003cbr /\u003e\n\nNeed to add that Apache 2.0 or Creative Commons License header to a source file? Just click-click:\n\n![](tools/readme/bcgovr_addin_licence.gif)\n\nYou can also use `insert_bcgov_apache_header()` or `insert_bcgov_cc_header()`.\n\n\u003cbr /\u003e\n\n\u003c/details\u003e\n\n\n\n\u003cdetails\u003e\u003csummary\u003e\u003cstrong\u003eInsert a bcgov project lifecycle badge into my README file\u003c/strong\u003e\u003c/summary\u003e\n\n\u003cbr /\u003e\n\nWant to add a lifecycle badge to your README file to indicate the current state of the project? Just click-click-click-click:\n\n![](tools/readme/bcgovr_addin_badge.gif)\n\nYou can also use `insert_bcgov_lifecycle_badge(\"experimental\")`. Type `?insert_bcgov_lifecycle_badge` in the R console for the list of badge options and other help.\n\n\u003c/details\u003e\n\n\n### Options\n\nThere are several options you can specify in your `.Rprofile` file to customise the default behaviour when using the `create_bcgov_` and `use_bcgov_` functions in `bcgovr`.\n\n* `bcgovr.coc.email`: Code of Conduct contact email address\n* `bcgovr.dir.struct`: Alternative project directory structure for `create_bcgov_project()`. This should be specified as a character vector of directory (i.e. folders) and file paths, relative to the root of the project.  Directories should be identified by having a trailing forward-slash (e.g., `\"dir/\"`).\n    \n    The default is: `c(\"R/\", \"data/\", \"out/\", \"01_load.R\", \"02_clean.R\", \"03_analysis.R\", \"04_output.R\", \"internal.R\", \"run_all.R\")`.\n\nTo make use of these options, there should be a section in your `.Rprofile` file that looks something like this:\n\n```r\nif (interactive()) {\n    options(\"bcgovr.coc.email\" = \"my.email@gov.bc.ca\")\n    options(\"bcgovr.dir.struct\" = c(\"doc/\", \"data/\", \"results/\", \"src/01_load.R\", \"src/02_clean.R\",\n            \"src/03_analysis.R\", \"src/04_output.R\", \"src/run_all.R\"))\n}\n```\n\nThe easiest way to edit your `.Rprofile` is to run `usethis::edit_r_profile()`. It will open \nup the file in RStudio for editing. Then save the file, restart R, and your settings \nwill be saved.\n\n## Project Status\n\nThis package is relatively stable and available for general use.\n\n## Getting Help or Reporting an Issue\n\nTo report bugs/issues/feature requests, please file an [Issue](https://github.com/bcgov/bcgovr/issues/).\n\n\n## How to Contribute\n\nIf you would like to contribute to the package, please see our \n[CONTRIBUTING](CONTRIBUTING.md) guidelines.\n\nPlease note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.\n\n\n## License\n\n    Copyright 2017 Province of British Columbia\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at \n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcgov%2Fbcgovr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcgov%2Fbcgovr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcgov%2Fbcgovr/lists"}