-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuser_categorisation.R
47 lines (38 loc) · 1.35 KB
/
user_categorisation.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
#' user_categorisation
#'
#' This function is used within the domain_mapping function. \cr \cr
#' It displays data properties to the user and requests a categorisation into a domain. \cr \cr
#' An optional note can be included with the categorisation.
#'
#' @param data_element Name of the variable
#' @param data_desc Description of the variable
#' @param data_type Data type of the variable
#' @return It returns a list containing the decision and decision note
#' @export
user_categorisation <- function(data_element,data_desc,data_type) {
# print text to R console
cat(paste(
"\nDATA ELEMENT -----> ", data_element,
"\n\nDESCRIPTION -----> ", data_desc,
"\n\nDATA TYPE -----> ", data_type, "\n"
))
state <- "redo"
while (state == "redo") {
# ask user for categorisation
decision <- ""
while (decision == "") {
cat("\n \n")
decision <- readline(prompt = "Categorise this variable: ")
}
# ask user for note on categorisation
decision_note <- ""
while (decision_note == "") {
cat("\n \n")
decision_note <- readline(prompt = "Notes (write 'N' if no notes): ")
}
# check if user wants to continue or redo
cat("\n \n")
state <- readline(prompt = "Press enter to continue or write 'redo' to correct previous answer: ")
}
return(list(decision = decision,decision_note = decision_note))
}