Open Science and Data Sharing

1 Preamble

1.1 Install Libraries

Code
#install.packages("remotes")
#remotes::install_github("DevPsyLab/petersenlab")
#remotes::install_github("paulhendricks/anonymizer")

1.2 Load Libraries

1.3 Simulate Data

Code
set.seed(52242)

sampleSize <- 100

ID <- 1:sampleSize
X <- rnorm(sampleSize)
Y <- rnorm(sampleSize)

mydata <- data.frame(
  ID = ID,
  X = X,
  Y = Y)

2 Preparing Data for Sharing

  1. Deidentify data
  2. Generate random anonymized participant ID

2.1 Deidentify Data

Before sharing data, it is important to remove any variables with identifying information.

2.2 Generate Random Anonymized Participant ID

To help protect participant anonymity, it is important to anonymize participant IDs when sharing data so participants’ 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.

Code
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)
Code
# 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
Code
# Remove the Original ID Column
mydata <- mydata |>
  select(-ID)

3 Session Info

Code
R version 4.6.1 (2026-06-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
 [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
[10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

time zone: UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] lubridate_1.9.5  forcats_1.0.1    stringr_1.6.0    dplyr_1.2.1     
 [5] purrr_1.2.2      readr_2.2.0      tidyr_1.3.2      tibble_3.3.1    
 [9] ggplot2_4.0.3    tidyverse_2.0.0  anonymizer_0.2.2

loaded via a namespace (and not attached):
 [1] gtable_0.3.6       jsonlite_2.0.0     compiler_4.6.1     tidyselect_1.2.1  
 [5] scales_1.4.0       yaml_2.3.12        fastmap_1.2.0      R6_2.6.1          
 [9] generics_0.1.4     knitr_1.51         htmlwidgets_1.6.4  tzdb_0.5.0        
[13] pillar_1.11.1      RColorBrewer_1.1-3 rlang_1.3.0        stringi_1.8.9     
[17] xfun_0.60          S7_0.2.2           otel_0.2.0         timechange_0.4.0  
[21] cli_3.6.6          withr_3.0.3        magrittr_2.0.5     digest_0.6.39     
[25] grid_4.6.1         hms_1.1.4          lifecycle_1.0.5    vctrs_0.7.3       
[29] evaluate_1.0.5     glue_1.8.1         farver_2.1.2       rmarkdown_2.31    
[33] tools_4.6.1        pkgconfig_2.0.3    htmltools_0.5.9   

Developmental Psychopathology Lab