-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathasFactorSimpleDS.R
More file actions
34 lines (28 loc) · 1.26 KB
/
asFactorSimpleDS.R
File metadata and controls
34 lines (28 loc) · 1.26 KB
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
#'
#' @title Converts a numeric vector into a factor
#' @description This function is an assign DataSHIELD function that coerces
#' a numeric or character vector into a factor
#' @details The functions converts the input variable into a factor. Unlike
#' ds.asFactor and its serverside functions, ds.asFactorSimple does no more than
#' coerce the class of a variable to factor in each study. It does not check for
#' or enforce consistency of factor levels across sources or allow you to
#' force an arbitrary set of levels unless those levels actually exist in the sources.
#' In addition, it does not allow you to create an array of
#' binary dummy variables that is equivalent to a factor. If you need to do any
#' of these things you will have to use the ds.asFactor function.
#' @param input.var.name the name of the variable that is to be converted to a factor.
#' @return an object of class factor
#' @export
#'
asFactorSimpleDS <- function(input.var.name=NULL){
input.var <- .loadServersideObject(input.var.name)
.checkClass(
obj = input.var,
obj_name = input.var.name,
permitted_classes = c("numeric", "integer", "character", "factor")
)
factor.obj <- factor(input.var)
return(factor.obj)
}
#ASSIGN FUNCTION
# asFactorSimpleDS