-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
74 lines (56 loc) · 2.48 KB
/
README.Rmd
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(rcpv)
```
# rcpv
R package for working with Common Procurement Vocabulary (CPV) codes. As described on [SIMAP](https://simap.ted.europa.eu/cpv "information system for public procurement (fr. système d'information pour les marchés publics)"):
> The CPV establishes a single classification system for public procurement aimed at standardising the references used (...) to describe the subject of procurement contracts.
> The CPV consists of a main vocabulary for defining the subject of a contract, and a supplementary vocabulary for adding further qualitative information. The main vocabulary is based on a tree structure comprising codes of up to 9 digits (an 8 digit code plus a check digit) associated with a wording that describes the type of supplies, works or services forming the subject of the contract.
## Installation
To install directly from GitHub:
```r
# install.packages("devtools")
library(devtools)
devtools::install_github("kaftanowicz/rcpv")
```
## Usage
The main function exported by this package is `describe_cpv`, which repairs given CPV codes if they are broken, classifies them at selected level of aggregation and returns their description in chosen language, shortened to desired number of characters.
```{r example_1}
cpv <- c("45212212-5", "34962220-6", "15961100-3")
describe_cpv(cpv)
describe_cpv(cpv, class_level = 5)
describe_cpv(cpv, class_level = 4)
describe_cpv(cpv, class_level = 3)
describe_cpv(cpv, class_level = 2)
describe_cpv(cpv, class_level = 1)
describe_cpv(cpv, class_level = 1, max_nchar = 30)
describe_cpv(cpv, lang = "DE")
```
Several of the functions called inside `describe_cpv` - `is_correct_cpv`, `correct_cpv`, `classify_cpv`, `convert_cpv`, `shorten_cpv`, `shorten_desc` - are available to the user on their own.
```{r example_2}
cpv <- c("45212212-5", "45212212 - 5", "452122125", "45.21.22.12.5")
is_correct_cpv(cpv)
correct_cpv(cpv)
```
```{r example_3}
cpv <- "45.21.22.12.5"
classify_cpv(cpv, class_level = 1)
```
```{r example_4}
cpv_2003 <- "01111000-8"
(cpv_2007 <- convert_cpv(cpv_2003, from2003to2007 = TRUE))
convert_cpv(cpv_2007, from2003to2007 = FALSE)
```
```{r example_5}
li <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
shorten_desc(li, max_nchar = 30, ending = "...")
```