|
1 | | -#' @title Coerces an R object into class numeric |
2 | | -#' @description this function is based on the native R function \code{as.numeric} |
| 1 | +#' @title Coerces an R object into class logical |
| 2 | +#' @description this function is based on the native R function \code{as.logical} |
3 | 3 | #' @details See help for function \code{as.logical} in native R |
4 | 4 | #' @param x.name the name of the input object to be coerced to class |
5 | | -#' numeric. Must be specified in inverted commas. But this argument is |
| 5 | +#' logical. Must be specified in inverted commas. But this argument is |
6 | 6 | #' usually specified directly by <x.name> argument of the clientside function |
7 | | -#' \code{ds.aslogical} |
| 7 | +#' \code{ds.asLogical} |
8 | 8 | #' @return the object specified by the <newobj> argument (or its default name |
9 | 9 | #' <x.name>.logic) which is written to the serverside. For further |
10 | 10 | #' details see help on the clientside function \code{ds.asLogical} |
11 | 11 | #' @author Amadou Gaye, Paul Burton for DataSHIELD Development Team |
12 | 12 | #' @export |
13 | 13 | asLogicalDS <- function (x.name){ |
14 | | - |
15 | | -if(is.character(x.name)){ |
16 | | - x<-eval(parse(text=x.name), envir = parent.frame()) |
17 | | - |
18 | | - }else{ |
19 | | - studysideMessage<-"ERROR: x.name must be specified as a character string" |
20 | | - stop(studysideMessage, call. = FALSE) |
21 | | - } |
22 | | - |
23 | | - if(!is.numeric(x)&&!is.integer(x)&&!is.character(x)&&!is.matrix(x)){ |
24 | | - studysideMessage<-"ERROR: for ds.asLogical function, x.name must specify an input object of class numeric, integer, character or matrix" |
25 | | - stop(studysideMessage, call. = FALSE) |
26 | | - } |
| 14 | + x <- .loadServersideObject(x.name) |
| 15 | + .checkClass(obj = x, obj_name = x.name, permitted_classes = c("numeric", "integer", "character", "matrix")) |
27 | 16 |
|
28 | 17 | output <- as.logical(x) |
29 | | - |
30 | 18 | return(output) |
31 | 19 | } |
32 | 20 | #ASSIGN FUNCTION |
|
0 commit comments