|
3 | 3 | #' @description This function is similar to R function \code{levels}. |
4 | 4 | #' @details The function returns the levels of the input vector or list. |
5 | 5 | #' @param x a factor vector |
6 | | -#' @return a list, the factor levels present in the vector |
| 6 | +#' @return a list with one element: \code{Levels} (the factor levels present |
| 7 | +#' in the vector) |
7 | 8 | #' @author Alex Westerberg, for DataSHIELD Development Team |
| 9 | +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands |
8 | 10 | #' @export |
9 | 11 | #' |
10 | 12 | levelsDS <- function(x){ |
11 | | - |
| 13 | + |
| 14 | + x.val <- .loadServersideObject(x) |
| 15 | + .checkClass(obj = x.val, obj_name = x, permitted_classes = "factor") |
| 16 | + |
12 | 17 | # Check Permissive Privacy Control Level. |
13 | 18 | dsBase::checkPermissivePrivacyControlLevel(c('permissive', 'banana', 'carrot')) |
14 | | - |
| 19 | + |
15 | 20 | ################################################################## |
16 | 21 | #MODULE 1: CAPTURE THE nfilter SETTINGS # |
17 | 22 | thr <- dsBase::listDisclosureSettingsDS() # |
18 | | - #nfilter.tab <- as.numeric(thr$nfilter.tab) # |
19 | | - #nfilter.glm <- as.numeric(thr$nfilter.glm) # |
20 | | - #nfilter.subset <- as.numeric(thr$nfilter.subset) # |
21 | | - #nfilter.string <- as.numeric(thr$nfilter.string) # |
22 | | - #nfilter.stringShort <- as.numeric(thr$nfilter.stringShort) # |
23 | | - #nfilter.kNN <- as.numeric(thr$nfilter.kNN) # |
24 | | - #nfilter.noise <- as.numeric(thr$nfilter.noise) # |
25 | 23 | nfilter.levels.density <- as.numeric(thr$nfilter.levels.density) # |
26 | | - #nfilter.levels.max <- as.numeric(thr$nfilter.levels.max) # |
27 | 24 | ################################################################## |
28 | | - |
| 25 | + |
29 | 26 | # find the levels of the input vector |
30 | | - out <- levels(x) |
31 | | - input.length <- length(x) |
| 27 | + out <- levels(x.val) |
| 28 | + input.length <- length(x.val) |
32 | 29 | output.length <- length(out) |
33 | | - studysideMessage <- "VALID ANALYSIS" |
34 | 30 |
|
35 | 31 | if((input.length * nfilter.levels.density) < output.length) { |
36 | | - out <- NA |
37 | | - studysideMessage <- "FAILED: Result length less than nfilter.levels.density of input length." |
38 | | - stop(studysideMessage, call. = FALSE) |
| 32 | + stop("FAILED: Result length less than nfilter.levels.density of input length.", call. = FALSE) |
39 | 33 | } |
40 | | - |
41 | | - out.obj <- list(Levels=out,ValidityMessage=studysideMessage) |
| 34 | + |
| 35 | + out.obj <- list(Levels=out) |
42 | 36 | return(out.obj) |
43 | 37 | } |
44 | 38 | #AGGREGATE FUNCTION |
|
0 commit comments