-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.qmd
127 lines (99 loc) · 4.77 KB
/
README.qmd
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
format: markdown_github
editor_options:
chunk_output_type: console
---
<!-- !!! ############################################################ !!! -->
<!-- This page is auto generated from `README.qmd`. -->
<!-- Don't change the .md file manually! -->
<!-- !!! ############################################################ !!! -->
# DIZtools <img src="man/figures/logo.png" align="right" width="120" />
<!-- badges: start -->
[![CRAN Status Badge](https://www.r-pkg.org/badges/version-ago/DIZtools)](https://cran.r-project.org/package=DIZtools)
[![Cran Checks](https://badges.cranchecks.info/worst/DIZtools.svg)](https://cran.r-project.org/web/checks/check_results_DIZtools.html)
[![](http://cranlogs.r-pkg.org/badges/grand-total/DIZtools?color=blue)](https://cran.r-project.org/package=DIZtools)
[![](http://cranlogs.r-pkg.org/badges/last-month/DIZtools?color=blue)](https://cran.r-project.org/package=DIZtools)
[![Dependencies](https://tinyverse.netlify.com/badge/DIZtools)](https://cran.r-project.org/package=DIZtools)
[![R CMD Check via {tic}](https://github.com/miracum/misc-diztools/workflows/R%20CMD%20Check%20via%20{tic}/badge.svg?branch=main)](https://github.com/miracum/misc-diztools)
[![linting](https://github.com/miracum/misc-diztools/workflows/lint/badge.svg?branch=main)](https://github.com/miracum/misc-diztools)
[![test-coverage](https://github.com/miracum/misc-diztools/workflows/test-coverage/badge.svg?branch=main)](https://github.com/miracum/misc-diztools)
[![codecov](https://codecov.io/gh/miracum/misc-diztools/branch/main/graph/badge.svg)](https://app.codecov.io/gh/miracum/misc-diztools)
<!-- badges: end -->
The R package `DIZtools` provides utility functions used for the R package development infrastructure inside the data integration centers ('DIZ') to standardize and facilitate repetitive tasks such as setting up a database connection or issuing notification messages and to avoid redundancy.
:bulb: `DIZtools` contains all "lightweighted" functions of [`DIZutils`](https://github.com/miracum/misc-dizutils) making it a lot quicker to install, while [`DIZutils`](https://github.com/miracum/misc-dizutils) has a lot of dependencies and system requirements.
## Installation
You can install `DIZtools` directly from CRAN:
```{r}
#| eval: false
install.packages("DIZtools")
```
The development version can be installed using
```{r}
#| eval: false
install.packages("remotes")
remotes::install_github("miracum/misc-diztools", ref = "dev")
```
## Exported functions
```{r echo=FALSE, include=FALSE}
base_path <- "./R/"
key_to_get_text_from <- "title"
must_include_keys <- "export"
pattern_for_key_to_get_text_from <- paste0("^(#' @", key_to_get_text_from," )")
files <- list.files(path = base_path, pattern = ".R$")
texts <- lapply(files, function(filename){
content <- DIZtools::file_lines_to_list(paste0(base_path, filename))
## Stop if no line starts with `#' @MUST_INCLUDE_KEY `:
for (key in must_include_keys) {
if (isFALSE(any(grepl(
pattern = paste0("^(#' @", key, ")"), x = content
)))) {
return(NA)
}
}
## Get line number of line starting with `#' @ELEMENT `:
line_start <- which(grepl(pattern = pattern_for_key_to_get_text_from, x = content))[[1]]
## Get line number of the following line starting with `#' @` indicating that
## there (minus one) is the end of the title:
line_end <- which(grepl(pattern = "^(#' @)", x = content))
line_end <- line_end[line_end > line_start][[1]] - 1
final_text <-
content[line_start:line_end] |>
gsub(pattern = pattern_for_key_to_get_text_from,
replacement = "",
x = _) |>
gsub(pattern = "^(#')",
replacement = "",
x = _) |>
DIZtools::trim.space() |>
paste(collapse = " ") |>
DIZtools::trim.space()
return(final_text)
})
external_function_ids <- which(!is.na(texts))
internal_function_ids <- setdiff(1:length(files), external_function_ids)
get_function_string <- function(files, texts){
## Replace NAs with empty string:
texts <- lapply(texts, function(x){ifelse(is.na(x), "", paste0(": ", x))})
return(paste0("- ",
paste0(
"[`",
files |> gsub(
pattern = ".R$",
replacement = "",
x = _
),
"()`](./R/",
files,
")",
texts
) |>
paste(collapse = "\n- ")))
}
```
`r get_function_string(files = files[external_function_ids], texts = texts[external_function_ids])`
## Internal functions
:bulb: Use with care. Can be used by typing `DIZtools:::internal_function_name()` (<- using three `:`). Not recommended.
`r get_function_string(files = files[internal_function_ids], texts = texts[internal_function_ids])`
## More Infos
* about MIRACUM: <https://www.miracum.org/>
* about the Medical Informatics Initiative: <https://www.medizininformatik-initiative.de/de/start>