-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathosf.qmd
More file actions
100 lines (73 loc) · 2.07 KB
/
osf.qmd
File metadata and controls
100 lines (73 loc) · 2.07 KB
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
---
title: "Open Science Framework"
---
# Preamble
## Install Libraries
```{r}
#install.packages("remotes")
#remotes::install_github("DevPsyLab/petersenlab")
#remotes::install_github("paulhendricks/anonymizer")
```
## Load Libraries
```{r}
library("anonymizer")
library("tidyverse")
```
## Simulate Data
```{r}
set.seed(52242)
sampleSize <- 100
ID <- 1:sampleSize
X <- rnorm(sampleSize)
Y <- rnorm(sampleSize)
mydata <- data.frame(
ID = ID,
X = X,
Y = Y)
```
# Generate Random Anonymized ID {#sec-anonymizedID}
To help protect participant anonymity, it is important to anonymize participant IDs so their data cannot be stitched together across papers.
To anonymize participant IDs, use the following script and change the seed for every paper so that a given participant gets a different anonymized code each time.
```{r}
#| eval: false
library("tidyverse")
library("remotes")
#install.packages("anonymizer")
remotes::install_github("paulhendricks/anonymizer")
library("anonymizer")
library("tidyverse")
# Generate Random Anonymized ID
mydata$anonymizedID <- anonymize(c(
mydata$ID),
.algo = "crc32",
.seed = 20230426) # change seed for every paper (based on the date) so that participant gets a new code each time
# Re-Sort Data by Random Anonymized ID to Mix-Up Participants (so they are not in the same order for every paper)
mydata <- mydata %>%
select(anonymizedID, everything()) %>%
arrange(anonymizedID)
# Remove the Original ID Column
mydata <- mydata %>%
select(-ID)
```
```{r}
#| code-fold: true
# Generate Random Anonymized ID
mydata$anonymizedID <- anonymize(c(
mydata$ID),
.algo = "crc32",
.seed = 20230426) # change seed for every paper (based on the date) so that participant gets a new code each time
# Re-Sort Data by Random Anonymized ID to Mix-Up Participants (so they are not in the same order for every paper)
mydata <- mydata %>%
select(anonymizedID, everything()) %>%
arrange(anonymizedID)
# Print the Data
mydata
# Remove the Original ID Column
mydata <- mydata %>%
select(-ID)
```
# Session Info
```{r}
#| code-fold: true
sessionInfo()
```