use_bridge: Use a new sector-classification bridge in r2dii.data

Description Usage Arguments Value Examples

View source: R/use_bridge.R

Description

This is a developer-facing function that helps create the pull request you need to add a new sector-classification bridge to the package r2dii.data (example). It does create a commit but it does change your working tree: It adds new files and modifies existing files. If the result is now what you want, you may restore the last commit with something like git checkout . && git clean -i. Normally you would call this function from inside the project that contains the source code of the package r2dii.data.

Usage

1
use_bridge(dataset, data, contributor = NULL, issue = NULL, overwrite = FALSE)

Arguments

dataset

String. Name of the dataset. This is used as the "prefix" to for an object-name of the form [prefix]_classification, e.g. psic_classification.

data

A data frame.

contributor

String. Name of a contributor to thank in NEWS.md, e.g. "\@daisy-pacheco".

issue

String. Number of related issue or PR, e.g. #199.

overwrite

Logical. Allow overwriting data?

Value

This function is called for its side effects of adding and modifying files. It returns the first argument invisibly.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Not run: 
# Work form inside r2dii.data (here I use from a temporary copy)
old <- getwd()
r2dii_data <- file.path(tempdir(), "r2dii.data")
fs::dir_create(r2dii_data)
setwd(r2dii_data)
system("git clone https://github.com/2DegreesInvesting/r2dii.data.git -- .")
devtools::load_all()

library(r2dii.usethis)

# This is usually a contributed spreadsheet
dataset <- "fake"
data <- data.frame(
  original_code = letters[1:3],
  code_level = 5,
  code = as.character(1:3),
  sector = "not in scope",
  borderline = FALSE
)
contributor <- "@somebody"
issue <- "#123"
use_bridge(dataset, data, contributor, issue)

# Notice what changed
system("git status -s")

# Teardown ----------------------------------------------------------------
unlink(r2dii_data, recursive = TRUE)
setwd(old)

## End(Not run)

2DegreesInvesting/r2dii.usethis documentation built on Feb. 22, 2022, 9:47 a.m.