/
generic.R
187 lines (157 loc) · 5.61 KB
/
generic.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#_______________________________________________________________________________
#---- getCovariates ----
#_______________________________________________________________________________
#' Get all covariates (fixed / time-varying / event covariates).
#'
#' @param object any object
#' @return all covariates from object
#' @export
#' @rdname getCovariates
getCovariates <- function(object) {
stop("No default function is provided")
}
setGeneric("getCovariates", function(object) {
standardGeneric("getCovariates")
})
#_______________________________________________________________________________
#---- getEventCovariates ----
#_______________________________________________________________________________
#' Get all event-related covariates.
#'
#' @param object any object
#' @return all event-related covariates from object
#' @export
#' @rdname getEventCovariates
getEventCovariates <- function(object) {
stop("No default function is provided")
}
setGeneric("getEventCovariates", function(object) {
standardGeneric("getEventCovariates")
})
#_______________________________________________________________________________
#---- getFixedCovariates ----
#_______________________________________________________________________________
#' Get all fixed covariates.
#'
#' @param object any object
#' @return all fixed covariates from object
#' @export
#' @rdname getFixedCovariates
getFixedCovariates <- function(object) {
stop("No default function is provided")
}
setGeneric("getFixedCovariates", function(object) {
standardGeneric("getFixedCovariates")
})
#_______________________________________________________________________________
#---- getTimeVaryingCovariates ----
#_______________________________________________________________________________
#' Get all time-varying covariates.
#'
#' @param object any object
#' @return all time-varying covariates from object
#' @export
#' @rdname getTimeVaryingCovariates
getTimeVaryingCovariates <- function(object) {
stop("No default function is provided")
}
setGeneric("getTimeVaryingCovariates", function(object) {
standardGeneric("getTimeVaryingCovariates")
})
#_______________________________________________________________________________
#---- getIOVs ----
#_______________________________________________________________________________
#' Get all IOV objects.
#'
#' @param object any object
#' @return all IOV's from object
#' @export
#' @rdname getIOVs
getIOVs <- function(object) {
stop("No default function is provided")
}
setGeneric("getIOVs", function(object) {
standardGeneric("getIOVs")
})
#_______________________________________________________________________________
#---- getOccasions ----
#_______________________________________________________________________________
#' Get all occasions.
#'
#' @param object any object
#' @return all occasions from object
#' @export
#' @rdname getOccasions
getOccasions <- function(object) {
stop("No default function is provided")
}
setGeneric("getOccasions", function(object) {
standardGeneric("getOccasions")
})
#_______________________________________________________________________________
#---- getTimes ----
#_______________________________________________________________________________
#' Get all distinct times for the specified object.
#'
#' @param object any object
#' @return numeric vector with all unique times, sorted
#' @export
#' @rdname getTimes
getTimes <- function(object) {
stop("No default function is provided")
}
setGeneric("getTimes", function(object) {
standardGeneric("getTimes")
})
#_______________________________________________________________________________
#---- setLabel ----
#_______________________________________________________________________________
#' Set the label.
#'
#' @param object any object that has a label
#' @param x the new label
#' @return the updated object
#' @export
#' @rdname setLabel
setLabel <- function(object, x) {
stop("No default function is provided")
}
setGeneric("setLabel", function(object, x) {
standardGeneric("setLabel")
})
#_______________________________________________________________________________
#---- sample ----
#_______________________________________________________________________________
#' Sample generic object.
#'
#' @param object generic object
#' @param n number of samples required
#' @param ... extra arguments
#' @return sampling result
#' @export
#' @rdname sample
sample <- function(object, n, ...) {
stop("No default function is provided")
}
setGeneric("sample", function(object, n, ...) {
standardGeneric("sample")
})
#_______________________________________________________________________________
#---- setSubjects ----
#_______________________________________________________________________________
#' Set the number of subjects.
#'
#' @param object any object
#' @param x the new number of subjects
#' @return the updated object
#' @export
#' @rdname setSubjects
setSubjects <- function(object, x) {
stop("No default function is provided")
}
setGeneric("setSubjects", function(object, x) {
if (is.numeric(x)) {
x <- as.integer(x)
}
standardGeneric("setSubjects")
})