-
Notifications
You must be signed in to change notification settings - Fork 1
/
Discrete.R
95 lines (91 loc) · 2.12 KB
/
Discrete.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
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
Discrete <- setClass("Discrete",
contains = "Column",
slots = c(key = "list",
value = "list")
)
setGeneric(name = "getValue",
def = function(theObject)
{
standardGeneric("getValue")
}
)
setMethod(f = "getValue",
signature = "Discrete",
definition = function(theObject)
{
return(theObject@value)
}
)
setGeneric(name = "setValue",
def = function(theObject, newValue, add = FALSE)
{
standardGeneric("setValue")
}
)
setMethod(f = "setValue",
signature = "Discrete",
definition = function(theObject, newValue)#, add = FALSE)
{
# if(add)
# {
# theObject@value <- c(theObject@value, newValue)
# }else
# {
theObject@value <- as.list(newValue)
#}
return(theObject)
}
)
setGeneric(name = "getKey",
def = function(theObject)
{
standardGeneric("getKey")
}
)
setMethod(f = "getKey",
signature = "Discrete",
definition = function(theObject)
{
return(theObject@key)
}
)
setGeneric(name = "setKey",
def = function(theObject, newKey, add = FALSE)
{
standardGeneric("setKey")
}
)#!!!!!!!!!!!
setMethod(f = "setKey",
signature = "Discrete",
definition = function(theObject, newKey)#, add = FALSE)
{
if (!is.list(newKey)) newKey <- list(newKey)
for(i in 1:length(newKey))
{
# if(add)
# {
# theObject@key[[i]] <- c(theObject@key[[i]], as.list(newKey[[i]]))
# }else
# {
theObject@key[[i]] <- as.list(newKey[[i]])
#}
}
return(theObject)
}
)
#setKey(sex, list(c("male", "m"), c("female", "f")), add = TRUE)
#setKey(diabetes, list(c("2 òèï", "2òèï", "âòîðîé", "2")), add = TRUE)
setGeneric(name = "FindErrors",
def = function(theObject, myfile_in, myfile_out, myfile_report, misprints, missing_values, unsolved_misprints)
{
standardGeneric("FindErrors")
}
)
setMethod(f = "FindErrors",
signature = "Discrete",
definition = function(theObject, myfile_in, myfile_out, myfile_report, misprints, missing_values, unsolved_misprints)
{
output_list <- FindMisprints(misprints, missing_values, unsolved_misprints, myfile_in, myfile_out, myfile_report, theObject)
return(output_list)
}
)