/
asIntegerDS.R
31 lines (27 loc) · 1.17 KB
/
asIntegerDS.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
#'
#' @title Coerces an R object into class integer
#' @description This function is based on the native R function \code{as.integer}.
#' @details See help for function \code{as.integer} in native R, and details section
#' in the help file of the clientside function \code{ds.asInteger}.
#' @param x.name the name of the input object to be coerced to class
#' integer. Must be specified in inverted commas. But this argument is
#' usually specified directly by <x.name> argument of the clientside function
#' \code{ds.asInteger}.
#' @return the object specified by the <newobj> argument (or its default name
#' <x.name>.int) which is written to the serverside. For further
#' details see help on the clientside function \code{ds.asInteger}.
#' @author Amadou Gaye, Paul Burton, Demetris Avraam, for DataSHIELD Development Team
#' @export
#'
asIntegerDS <- function(x.name){
if(is.character(x.name)){
x <- eval(parse(text=x.name), envir = parent.frame())
}else{
studysideMessage <- "ERROR: x.name must be specified as a character string"
return(list(studysideMessage=studysideMessage))
}
output <- as.integer(as.character(x))
return(output)
}
# ASSIGN FUNCTION
# asIntegerDS