-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_id.R
executable file
·54 lines (36 loc) · 1.7 KB
/
new_id.R
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
main <- function() {
if (!require("readxl")) {
install.packages("readxl")
}
if (!require("xlsx")) {
install.packages("xlsx")
}
if (!require("dplyr")) {
install.packages("dplyr")
}
library(dplyr)
library(readxl)
library(xlsx)
dataDirectory <- "OMITTED"
setwd(dataDirectory)
blood_S_all <- read_excel("GCRC Blood Analysis Patient Records.xlsm",sheet = "OMITTED", col_types=c("text","text","text","date","numeric","text","text","date","text","date","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text"))
stool_S <- read_excel("GCRC Stool Analysis Patient Records.xlsm",sheet = "OMITTED", col_types=c("text","text","text","date","numeric","text","text","date","text","date","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text","text"))
blood <- blood_S_all %>% distinct(Patient_Name) %>% filter(!is.na(Patient_Name))
stool <- stool_S %>% distinct(Patient_Name) %>% filter(!is.na(Patient_Name))
all <- full_join(blood, stool)
PatientID <- c()
for(i in 1:nrow(all)) {
PatientID <- c(PatientID, paste("MM", i, sep=""))
}
PatientID <- data.frame(PatientID)
all <- cbind(all,PatientID)
cat("\nIn what directory would you like to put this file?\n")
input <- readline(prompt="Enter here: ")
setwd(input)
filename <- "Patientkey.xlsx"
if(file.exists(filename)) {
file.remove(filename)
}
write.xlsx2(all, filename, sheetName = "OMITTED",col.names = T,row.names = F,append = T)
}
main()