R code for generating unique identifiers for use in survey research. The code can be found in the file generating-ids.R
.
The code is associated with the following publication:
Vogel, D. (2018). Matching survey responses with anonymity in environments with privacy concerns: A practical guide. International Journal of Public Sector Management, 31(7): 742–754. https://doi.org/10.1108/IJPSM-12-2017-0330. Open Access Post-Print: https://doi.org/10.31235/osf.io/nwjd7
- If not already done: install the packages
random
andwritexl
by typinginstall.packages("random", dep = TRUE)
andinstall.packages("writexl", dep = TRUE)
- Download the file
generating-ids.R
or copy the content of the file - Modify the number of identifiers you need in line 18 (
amount <- 200
). Notice, that you cannot generate more than 10,000 IDs. - Modify the length of the identifiers in line 19 (
length <- 4
). - Run the code. It generates approx. the amount of required identifiers, deletes identifiers with characters with a high likelihood of confusion, and asks for a location to store the file with the identifiers.
The script uses random
(Eddelbuettel, 2017) to generate the identifiers and writexl
(Ooms, 2017) to save the results in an Excel file.
There is a Code Ocean Capsule of the code that ensures computational reproducibility: https://codeocean.com/capsule/9795597
Eddelbuettel, D. (2017). random: True Random Numbers using RANDOM.ORG. Retrieved from https://CRAN.R-project.org/package=random
Ooms, J. (2017). writexl: Export Data Frames to ’xlsx’ Format. Retrieved from https://CRAN.R-project.org/package=writexl