-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
88 lines (64 loc) · 1.43 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
75
76
77
78
79
80
81
82
83
84
85
86
---
output: github_document
#output: pdf_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r message=FALSE, warning=FALSE, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
devtools::load_all()
library(data.table)
```
# HRHRpal
The goal of HRHRpal is to ...
## Installation
You can install HRHRpal from the Folkehelseinstituttet repository via:
```{r gh-installation, eval = FALSE}
r <- getOption("repos")
r["fhi"] = "https://folkehelseinstituttet.github.io/drat/"
options(repos = r)
install.packages("HRHRpal")
```
## ProtectIdentifier
```{r, echo = FALSE}
data <- data.frame(id=c(
1001,
1001,
1002,
1001,
1003,
1003
))
data$weight <- c(41,42,43,44,45,46)
setDT(data)
```
This function takes a data.table (`data`) with a numerical identifier (`id`).
```{r}
print(data)
```
We can then apply the `ProtectIdentifier` function to `data`.
```{r}
key <- ProtectIdentifier(data=data,identifier = "id", seed=4)
```
`ProtectIdentifier` works by obtaining a list of all unique values of the identifier
```{r echo=FALSE}
print(key[,"old"])
```
The rows are then sorted randomly:
```{r echo=FALSE}
setorder(key,new)
print(key[,"old"])
```
The rows are then numbered:
```{r echo=FALSE}
print(key)
```
The new values are then assigned to the original dataset:
```{r echo=FALSE}
print(data)
```