From 35eb73228c05b7a000bbf036e4b001868f48fc1e Mon Sep 17 00:00:00 2001 From: Tim Cadman <41470917+timcadman@users.noreply.github.com> Date: Tue, 10 Mar 2026 22:30:02 +0100 Subject: [PATCH 1/7] refactor: batch 1 client functions remove redundant server calls --- DESCRIPTION | 1 + R/ds.abs.R | 72 +++++++------------ R/ds.asCharacter.R | 158 +++++++++-------------------------------- R/ds.asDataMatrix.R | 162 +++++++++--------------------------------- R/ds.asInteger.R | 160 +++++++++--------------------------------- R/ds.asList.R | 86 +++++++++-------------- R/ds.asLogical.R | 165 ++++++++++--------------------------------- R/ds.asMatrix.R | 164 ++++++++++--------------------------------- R/ds.asNumeric.R | 166 ++++++++++---------------------------------- R/ds.exp.R | 83 ++++++++-------------- R/ds.log.R | 81 ++++++++------------- R/ds.sqrt.R | 70 ++++++------------- R/utils.R | 51 ++++++++++++++ 13 files changed, 392 insertions(+), 1027 deletions(-) create mode 100644 R/utils.R diff --git a/DESCRIPTION b/DESCRIPTION index ad8e28a6d..5203957ad 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -62,6 +62,7 @@ Depends: R (>= 4.0.0), DSI (>= 1.7.1) Imports: + cli, fields, metafor, meta, diff --git a/R/ds.abs.R b/R/ds.abs.R index 41c204551..3a27b20ad 100644 --- a/R/ds.abs.R +++ b/R/ds.abs.R @@ -1,16 +1,16 @@ #' #' @title Computes the absolute values of a variable -#' @description Computes the absolute values for a specified numeric or integer vector. +#' @description Computes the absolute values for a specified numeric or integer vector. #' This function is similar to R function \code{abs}. -#' @details The function calls the server-side function \code{absDS} that computes the -#' absolute values of the elements of a numeric or integer vector and assigns a new vector -#' with those absolute values on the server-side. The name of the new generated vector is +#' @details The function calls the server-side function \code{absDS} that computes the +#' absolute values of the elements of a numeric or integer vector and assigns a new vector +#' with those absolute values on the server-side. The name of the new generated vector is #' specified by the user through the argument \code{newobj}, otherwise is named by default to #' \code{abs.newobj}. #' @param x a character string providing the name of a numeric or an integer vector. #' @param newobj a character string that provides the name for the output variable -#' that is stored on the data servers. Default name is set to \code{abs.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +#' that is stored on the data servers. Default name is set to \code{abs.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. #' If the \code{datasources} argument is not specified the default set of connections will be #' used: see \code{\link[DSI]{datashield.connections_default}}. #' @return \code{ds.abs} assigns a vector for each study that includes the absolute values of @@ -22,30 +22,30 @@ #' \dontrun{ #' #' # Connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') -#' +#' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") -#' +#' #' logindata <- builder$build() -#' +#' #' # Log onto the remote Opal training servers -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Example 1: Generate a normally distributed variable with zero mean and variance equal #' # to one and then get their absolute values #' ds.rNorm(samp.size=100, mean=0, sd=1, newobj='var.norm', datasources=connections) @@ -53,11 +53,11 @@ #' ds.summary(x='var.norm', datasources=connections) #' ds.abs(x='var.norm', newobj='var.norm.abs', datasources=connections) #' # check now the changes in the quantiles -#' ds.summary(x='var.norm.abs', datasources=connections) +#' ds.summary(x='var.norm.abs', datasources=connections) #' #' # Example 2: Generate a sequence of negative integer numbers from -200 to -100 #' # and then get their absolute values -#' ds.seq(FROM.value.char = '-200', TO.value.char = '-100', BY.value.char = '1', +#' ds.seq(FROM.value.char = '-200', TO.value.char = '-100', BY.value.char = '1', #' newobj='negative.integers', datasources=connections) #' # check the quantiles #' ds.summary(x='negative.integers', datasources=connections) @@ -66,47 +66,23 @@ #' ds.summary(x='positive.integers', datasources=connections) #' #' # clear the Datashield R sessions and logout -#' datashield.logout(connections) +#' datashield.logout(connections) #' #' } #' ds.abs <- function(x=NULL, newobj=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if(is.null(x)){ stop("Please provide the name of the input object!", call.=FALSE) } - # check if the input object is defined in all the studies - isDefined(datasources, x) - - # call the internal function that checks the input object is of the same class in all studies. - typ <- checkClass(datasources, x) - - # call the internal function that checks the input object(s) is(are) of the same class in all studies. - if(!('numeric' %in% typ) && !('integer' %in% typ)){ - stop("Only objects of type 'numeric' or 'integer' are allowed.", call.=FALSE) - } - - # create a name by default if the user did not provide a name for the new variable if(is.null(newobj)){ newobj <- "abs.newobj" } - # call the server side function that does the operation cally <- call("absDS", x) DSI::datashield.assign(datasources, newobj, cally) - # check that the new object has been created and display a message accordingly - finalcheck <- isAssigned(datasources, newobj) - } diff --git a/R/ds.asCharacter.R b/R/ds.asCharacter.R index c0bd4ce0a..d349a6cc2 100644 --- a/R/ds.asCharacter.R +++ b/R/ds.asCharacter.R @@ -1,167 +1,71 @@ -#' +#' #' @title Converts a server-side R object into a character class -#' @description Converts the input object into a character class. +#' @description Converts the input object into a character class. #' This function is based on the native R function \code{as.character}. -#' @details +#' @details #' Server function called: \code{asCharacterDS} -#' +#' #' @param x.name a character string providing the name of the input object to be coerced to class #' character. #' @param newobj a character string that provides the name for the output object -#' that is stored on the data servers. Default \code{ascharacter.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' that is stored on the data servers. Default \code{ascharacter.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. -#' @return \code{ds.asCharacter} returns the object converted into a class character -#' that is written to the server-side. Also, two validity messages are returned to the client-side -#' indicating the name of the \code{newobj} which has been created in each data source and if -#' it is in a valid form. -#' @examples +#' @return \code{ds.asCharacter} returns the object converted into a class character +#' that is written to the server-side. +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into a class character #' ds.asCharacter(x.name = "D$LAB_TSC", #' newobj = "char.obj", #' datasources = connections[1]) #only the first Opal server is used ("study1") -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } #' @author DataSHIELD Development Team #' @export -#' +#' ds.asCharacter <- function(x.name=NULL, newobj=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if(is.null(x.name)){ stop("Please provide the name of the input vector!", call.=FALSE) } - - # check if the input object is defined in all the studies - isDefined(datasources, x.name) - # create a name by default if user did not provide a name for the new variable if(is.null(newobj)){ newobj <- "ascharacter.newobj" } - # call the server side function that does the job - - calltext <- call("asCharacterDS", x.name) - - DSI::datashield.assign(datasources, newobj, calltext) - - -############################################################################################################# -#DataSHIELD CLIENTSIDE MODULE: CHECK KEY DATA OBJECTS SUCCESSFULLY CREATED # - # -#SET APPROPRIATE PARAMETERS FOR THIS PARTICULAR FUNCTION # -test.obj.name<-newobj # - # # - # -# CALL SEVERSIDE FUNCTION # -calltext <- call("testObjExistsDS", test.obj.name) # - # -object.info<-DSI::datashield.aggregate(datasources, calltext) # - # -# CHECK IN EACH SOURCE WHETHER OBJECT NAME EXISTS # -# AND WHETHER OBJECT PHYSICALLY EXISTS WITH A NON-NULL CLASS # -num.datasources<-length(object.info) # - # - # -obj.name.exists.in.all.sources<-TRUE # -obj.non.null.in.all.sources<-TRUE # - # -for(j in 1:num.datasources){ # - if(!object.info[[j]]$test.obj.exists){ # - obj.name.exists.in.all.sources<-FALSE # - } # - if(is.null(object.info[[j]]$test.obj.class) || ("ABSENT" %in% object.info[[j]]$test.obj.class)){ # - obj.non.null.in.all.sources<-FALSE # - } # - } # - # -if(obj.name.exists.in.all.sources && obj.non.null.in.all.sources){ # - # - return.message<- # - paste0("A data object <", test.obj.name, "> has been created in all specified data sources") # - # - # - }else{ # - # - return.message.1<- # - paste0("Error: A valid data object <", test.obj.name, "> does NOT exist in ALL specified data sources") # - # - return.message.2<- # - paste0("It is either ABSENT and/or has no valid content/class,see return.info above") # - # - return.message.3<- # - paste0("Please use ds.ls() to identify where missing") # - # - # - return.message<-list(return.message.1,return.message.2,return.message.3) # - # - } # - # - calltext <- call("messageDS", test.obj.name) # - studyside.message<-DSI::datashield.aggregate(datasources, calltext) # - # - no.errors<-TRUE # - for(nd in 1:num.datasources){ # - if(studyside.message[[nd]]!="ALL OK: there are no studysideMessage(s) on this datasource"){ # - no.errors<-FALSE # - } # - } # - # - # - if(no.errors){ # - validity.check<-paste0("<",test.obj.name, "> appears valid in all sources") # - return(list(is.object.created=return.message,validity.check=validity.check)) # - } # - # -if(!no.errors){ # - validity.check<-paste0("<",test.obj.name,"> invalid in at least one source. See studyside.messages:") # - return(list(is.object.created=return.message,validity.check=validity.check, # - studyside.messages=studyside.message)) # - } # - # -#END OF CHECK OBJECT CREATED CORECTLY MODULE # -############################################################################################################# - + calltext <- call("asCharacterDS", x.name) + DSI::datashield.assign(datasources, newobj, calltext) } -# ds.asCharacter diff --git a/R/ds.asDataMatrix.R b/R/ds.asDataMatrix.R index 7b4833bbd..976986dbe 100644 --- a/R/ds.asDataMatrix.R +++ b/R/ds.asDataMatrix.R @@ -1,166 +1,70 @@ -#' @title Converts a server-side R object into a matrix +#' @title Converts a server-side R object into a matrix #' @description Coerces an R object into a matrix maintaining original -#' class for all columns in data frames. -#' @details This function is based on the native R function \code{data.matrix}. -#' +#' class for all columns in data frames. +#' @details This function is based on the native R function \code{data.matrix}. +#' #' Server function called: \code{asDataMatrixDS}. -#' @param x.name a character string providing the name of the input object to be coerced to -#' a matrix. +#' @param x.name a character string providing the name of the input object to be coerced to +#' a matrix. #' @param newobj a character string that provides the name for the output object #' that is stored on the data servers. Default \code{asdatamatrix.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. -#' @return \code{ds.asDataMatrix} returns the object converted into a matrix -#' that is written to the server-side. Also, two validity messages are returned -#' to the client-side -#' indicating the name of the \code{newobj} which -#' has been created in each data source and if -#' it is in a valid form. -#' @examples +#' @return \code{ds.asDataMatrix} returns the object converted into a matrix +#' that is written to the server-side. +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into a matrix #' ds.asDataMatrix(x.name = "D", #' newobj = "mat.obj", #' datasources = connections[1]) #only the first Opal server is used ("study1") -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } #' @author DataSHIELD Development Team #' @export -#' +#' ds.asDataMatrix <- function(x.name=NULL, newobj=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if(is.null(x.name)){ stop("Please provide the name of the input vector!", call.=FALSE) } - - # check if the input object is defined in all the studies - isDefined(datasources, x.name) - - # create a name by default if user did not provide a name for the new variable + if(is.null(newobj)){ newobj <- "asdatamatrix.newobj" } - # call the server side function that does the job - calltext <- call("asDataMatrixDS", x.name) - DSI::datashield.assign(datasources, newobj, calltext) - - -############################################################################################################# -#DataSHIELD CLIENTSIDE MODULE: CHECK KEY DATA OBJECTS SUCCESSFULLY CREATED # - # -#SET APPROPRIATE PARAMETERS FOR THIS PARTICULAR FUNCTION # -test.obj.name<-newobj # - # # - # -# CALL SEVERSIDE FUNCTION # -calltext <- call("testObjExistsDS", test.obj.name) # - # -object.info<-DSI::datashield.aggregate(datasources, calltext) # - # -# CHECK IN EACH SOURCE WHETHER OBJECT NAME EXISTS # -# AND WHETHER OBJECT PHYSICALLY EXISTS WITH A NON-NULL CLASS # -num.datasources<-length(object.info) # - # - # -obj.name.exists.in.all.sources<-TRUE # -obj.non.null.in.all.sources<-TRUE # - # -for(j in 1:num.datasources){ # - if(!object.info[[j]]$test.obj.exists){ # - obj.name.exists.in.all.sources<-FALSE # - } # - if(is.null(object.info[[j]]$test.obj.class) || ("ABSENT" %in% object.info[[j]]$test.obj.class)){ # - obj.non.null.in.all.sources<-FALSE # - } # - } # - # -if(obj.name.exists.in.all.sources && obj.non.null.in.all.sources){ # - # - return.message<- # - paste0("A data object <", test.obj.name, "> has been created in all specified data sources") # - # - # - }else{ # - # - return.message.1<- # - paste0("Error: A valid data object <", test.obj.name, "> does NOT exist in ALL specified data sources") # - # - return.message.2<- # - paste0("It is either ABSENT and/or has no valid content/class,see return.info above") # - # - return.message.3<- # - paste0("Please use ds.ls() to identify where missing") # - # - # - return.message<-list(return.message.1,return.message.2,return.message.3) # - # - } # - # - calltext <- call("messageDS", test.obj.name) # - studyside.message<-DSI::datashield.aggregate(datasources, calltext) # - # - no.errors<-TRUE # - for(nd in 1:num.datasources){ # - if(studyside.message[[nd]]!="ALL OK: there are no studysideMessage(s) on this datasource"){ # - no.errors<-FALSE # - } # - } # - # - # - if(no.errors){ # - validity.check<-paste0("<",test.obj.name, "> appears valid in all sources") # - return(list(is.object.created=return.message,validity.check=validity.check)) # - } # - # -if(!no.errors){ # - validity.check<-paste0("<",test.obj.name,"> invalid in at least one source. See studyside.messages:") # - return(list(is.object.created=return.message,validity.check=validity.check, # - studyside.messages=studyside.message)) # - } # - # -#END OF CHECK OBJECT CREATED CORECTLY MODULE # -############################################################################################################# - + calltext <- call("asDataMatrixDS", x.name) + DSI::datashield.assign(datasources, newobj, calltext) } -# ds.asDataMatrix diff --git a/R/ds.asInteger.R b/R/ds.asInteger.R index 9b3b1a397..33d1bb82f 100644 --- a/R/ds.asInteger.R +++ b/R/ds.asInteger.R @@ -1,12 +1,12 @@ -#' @title Converts a server-side R object into an integer class +#' @title Converts a server-side R object into an integer class #' @description Coerces an R object into an integer class. #' This function is based on the native R function \code{as.integer}. -#' @details This function is based on the native R function \code{as.integer}. -#' The only difference is that the DataSHIELD -#' function first converts the values of the input object into characters and then convert -#' those to integers. This addition, +#' @details This function is based on the native R function \code{as.integer}. +#' The only difference is that the DataSHIELD +#' function first converts the values of the input object into characters and then convert +#' those to integers. This addition, #' it is important for the case where the input object is of class -#' factor having integers as levels. +#' factor having integers as levels. #' In that case, the native R \code{as.integer} function returns #' the underlying level codes and not the values as integers. #' For example \code{as.integer} in R @@ -15,162 +15,70 @@ #' Levels: 0 1 2 \cr #' to the following integer vector: #' 1 2 2 3 2 1 2 1 3 3 3 2 \cr -#' +#' #' Server function called: \code{asIntegerDS} -#' -#' @param x.name a character string providing the name of the input object to be coerced to -#' an integer. +#' +#' @param x.name a character string providing the name of the input object to be coerced to +#' an integer. #' @param newobj a character string that provides the name for the output object -#' that is stored on the data servers. Default \code{asinteger.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' that is stored on the data servers. Default \code{asinteger.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. #' @return \code{ds.asInteger} returns the R object converted into an integer -#' that is written to the server-side. Also, two validity messages are returned to the -#' client-side indicating the name of the \code{newobj} which -#' has been created in each data source and if -#' it is in a valid form. -#' @examples +#' that is written to the server-side. +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into an integer #' ds.asInteger(x.name = "D$LAB_TSC", #' newobj = "int.obj", #' datasources = connections[1]) #only the first Opal server is used ("study1") -#' ds.class(x = "int.obj", datasources = connections[1]) -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } +#' ds.class(x = "int.obj", datasources = connections[1]) +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } #' @author DataSHIELD Development Team #' @export ds.asInteger <- function(x.name=NULL, newobj=NULL, datasources=NULL){ - - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if(is.null(x.name)){ stop("Please provide the name of the input vector!", call.=FALSE) } - - # check if the input object is defined in all the studies - isDefined(datasources, x.name) - # create a name by default if user did not provide a name for the new variable if(is.null(newobj)){ newobj <- "asinteger.newobj" } - # call the server side function that does the job calltext <- call("asIntegerDS", x.name) DSI::datashield.assign(datasources, newobj, calltext) -############################################################################################################# -#DataSHIELD CLIENTSIDE MODULE: CHECK KEY DATA OBJECTS SUCCESSFULLY CREATED # - # -#SET APPROPRIATE PARAMETERS FOR THIS PARTICULAR FUNCTION # -test.obj.name<-newobj # - # # # -# CALL SEVERSIDE FUNCTION # -calltext <- call("testObjExistsDS", test.obj.name) # - # -object.info<-DSI::datashield.aggregate(datasources, calltext) # - # -# CHECK IN EACH SOURCE WHETHER OBJECT NAME EXISTS # -# AND WHETHER OBJECT PHYSICALLY EXISTS WITH A NON-NULL CLASS # -num.datasources<-length(object.info) # - # - # -obj.name.exists.in.all.sources<-TRUE # -obj.non.null.in.all.sources<-TRUE # - # -for(j in 1:num.datasources){ # - if(!object.info[[j]]$test.obj.exists){ # - obj.name.exists.in.all.sources<-FALSE # - } # - if(is.null(object.info[[j]]$test.obj.class) || ("ABSENT" %in% object.info[[j]]$test.obj.class)){ # - obj.non.null.in.all.sources<-FALSE # - } # - } # - # -if(obj.name.exists.in.all.sources && obj.non.null.in.all.sources){ # - # - return.message<- # - paste0("A data object <", test.obj.name, "> has been created in all specified data sources") # - # - # - }else{ # - # - return.message.1<- # - paste0("Error: A valid data object <", test.obj.name, "> does NOT exist in ALL specified data sources") # - # - return.message.2<- # - paste0("It is either ABSENT and/or has no valid content/class,see return.info above") # - # - return.message.3<- # - paste0("Please use ds.ls() to identify where missing") # - # - # - return.message<-list(return.message.1,return.message.2,return.message.3) # - # - } # - # - calltext <- call("messageDS", test.obj.name) # - studyside.message<-DSI::datashield.aggregate(datasources, calltext) # - # - no.errors<-TRUE # - for(nd in 1:num.datasources){ # - if(studyside.message[[nd]]!="ALL OK: there are no studysideMessage(s) on this datasource"){ # - no.errors<-FALSE # - } # - } # - # - # - if(no.errors){ # - validity.check<-paste0("<",test.obj.name, "> appears valid in all sources") # - return(list(is.object.created=return.message,validity.check=validity.check)) # - } # - # -if(!no.errors){ # - validity.check<-paste0("<",test.obj.name,"> invalid in at least one source. See studyside.messages:") # - return(list(is.object.created=return.message,validity.check=validity.check, # - studyside.messages=studyside.message)) # - } # - # -#END OF CHECK OBJECT CREATED CORECTLY MODULE # -############################################################################################################# - } -# ds.asInteger diff --git a/R/ds.asList.R b/R/ds.asList.R index d73668785..8338cf274 100644 --- a/R/ds.asList.R +++ b/R/ds.asList.R @@ -1,94 +1,72 @@ -#' -#' @title Converts a server-side R object into a list +#' +#' @title Converts a server-side R object into a list #' @description Coerces an R object into a list. #' This function is based on the native R function \code{as.list}. -#' @details -#' +#' @details +#' #' Server function called: \code{asListDS} -#' @param x.name a character string providing the name of the input object to be coerced to +#' @param x.name a character string providing the name of the input object to be coerced to #' a list. #' @param newobj a character string that provides the name for the output object -#' that is stored on the data servers. Default \code{aslist.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' that is stored on the data servers. Default \code{aslist.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. -#' @return \code{ds.asList} returns the R object converted into a list -#' which is written to the server-side. Also, two validity messages are returned to the -#' client-side indicating the name of the \code{newobj} which has been created in each data -#' source and if it is in a valid form. -#' @examples +#' @return \code{ds.asList} returns the R object converted into a list +#' which is written to the server-side. +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into a List #' ds.asList(x.name = "D", -#' newobj = "D.asList", +#' newobj = "D.asList", #' datasources = connections[1]) #only the first Opal server is used ("study1") -#' ds.class(x = "D.asList", datasources = connections[1]) -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } +#' ds.class(x = "D.asList", datasources = connections[1]) +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } #' @author DataSHIELD Development Team #' @export -#' +#' ds.asList <- function(x.name=NULL, newobj=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if(is.null(x.name)){ stop("Please provide the name of the input vector!", call.=FALSE) } - # check if the input object is defined in all the studies - isDefined(datasources, x.name) - - # create a name by default if user did not provide a name for the new variable if(is.null(newobj)){ newobj <- "aslist.newobj" } - # call the server side function that does the job - calltext <- call("asListDS", x.name, newobj) - out.message <- DSI::datashield.aggregate(datasources, calltext) -# print(out.message) - -#Don't include assign function completion module as it can print out an unhelpful -#warning message when newobj is a list } -# ds.asList diff --git a/R/ds.asLogical.R b/R/ds.asLogical.R index 2ddc33cfe..3fb2ae0d0 100644 --- a/R/ds.asLogical.R +++ b/R/ds.asLogical.R @@ -1,166 +1,71 @@ -#' @title Converts a server-side R object into a logical class +#' @title Converts a server-side R object into a logical class #' @description Coerces an R object into a logical class. -#' This function is based on the native R function \code{as.logical}. -#' @details -#' +#' This function is based on the native R function \code{as.logical}. +#' @details +#' #' Server function called: \code{asLogicalDS} -#' @param x.name a character string providing the name of the -#' input object to be coerced to a logical. +#' @param x.name a character string providing the name of the +#' input object to be coerced to a logical. #' @param newobj a character string that provides the name for the output object -#' that is stored on the data servers. Default \code{aslogical.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' that is stored on the data servers. Default \code{aslogical.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. #' @return \code{ds.asLogical} returns the R object converted into a logical -#' that is written to the server-side. Also, two validity messages are returned -#' to the client-side indicating the name of the \code{newobj} which -#' has been created in each data source and if -#' it is in a valid form. -#' @examples +#' that is written to the server-side. +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into a logical -#' ds.asLogical(x.name = "D$LAB_TSC", -#' newobj = "logical.obj", +#' ds.asLogical(x.name = "D$LAB_TSC", +#' newobj = "logical.obj", #' datasources =connections[1]) #only the first Opal server is used ("study1") -#' ds.class(x = "logical.obj", datasources = connections[1]) -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } +#' ds.class(x = "logical.obj", datasources = connections[1]) +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } #' @author DataSHIELD Development Team #' @export -#' +#' ds.asLogical <- function(x.name=NULL, newobj=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if(is.null(x.name)){ stop("Please provide the name of the input vector!", call.=FALSE) } - - # check if the input object is defined in all the studies - isDefined(datasources, x.name) - # create a name by default if user did not provide a name for the new variable if(is.null(newobj)){ newobj <- "aslogical.newobj" } - # call the server side function that does the job - calltext <- call("asLogicalDS", x.name) - DSI::datashield.assign(datasources, newobj, calltext) - - -############################################################################################################# -#DataSHIELD CLIENTSIDE MODULE: CHECK KEY DATA OBJECTS SUCCESSFULLY CREATED # - # -#SET APPROPRIATE PARAMETERS FOR THIS PARTICULAR FUNCTION # -test.obj.name<-newobj # - # # - # -# CALL SEVERSIDE FUNCTION # -calltext <- call("testObjExistsDS", test.obj.name) # - # -object.info<-DSI::datashield.aggregate(datasources, calltext) # - # -# CHECK IN EACH SOURCE WHETHER OBJECT NAME EXISTS # -# AND WHETHER OBJECT PHYSICALLY EXISTS WITH A NON-NULL CLASS # -num.datasources<-length(object.info) # - # - # -obj.name.exists.in.all.sources<-TRUE # -obj.non.null.in.all.sources<-TRUE # - # -for(j in 1:num.datasources){ # - if(!object.info[[j]]$test.obj.exists){ # - obj.name.exists.in.all.sources<-FALSE # - } # - if(is.null(object.info[[j]]$test.obj.class) || ("ABSENT" %in% object.info[[j]]$test.obj.class)){ # - obj.non.null.in.all.sources<-FALSE # - } # - } # - # -if(obj.name.exists.in.all.sources && obj.non.null.in.all.sources){ # - # - return.message<- # - paste0("A data object <", test.obj.name, "> has been created in all specified data sources") # - # - # - }else{ # - # - return.message.1<- # - paste0("Error: A valid data object <", test.obj.name, "> does NOT exist in ALL specified data sources") # - # - return.message.2<- # - paste0("It is either ABSENT and/or has no valid content/class,see return.info above") # - # - return.message.3<- # - paste0("Please use ds.ls() to identify where missing") # - # - # - return.message<-list(return.message.1,return.message.2,return.message.3) # - # - } # - # - calltext <- call("messageDS", test.obj.name) # - studyside.message<-DSI::datashield.aggregate(datasources, calltext) # - # - no.errors<-TRUE # - for(nd in 1:num.datasources){ # - if(studyside.message[[nd]]!="ALL OK: there are no studysideMessage(s) on this datasource"){ # - no.errors<-FALSE # - } # - } # - # - # - if(no.errors){ # - validity.check<-paste0("<",test.obj.name, "> appears valid in all sources") # - return(list(is.object.created=return.message,validity.check=validity.check)) # - } # - # -if(!no.errors){ # - validity.check<-paste0("<",test.obj.name,"> invalid in at least one source. See studyside.messages:") # - return(list(is.object.created=return.message,validity.check=validity.check, # - studyside.messages=studyside.message)) # - } # - # -#END OF CHECK OBJECT CREATED CORECTLY MODULE # -############################################################################################################# - + calltext <- call("asLogicalDS", x.name) + DSI::datashield.assign(datasources, newobj, calltext) } -# ds.asLogical diff --git a/R/ds.asMatrix.R b/R/ds.asMatrix.R index 1c5b0ced7..141b58c1d 100644 --- a/R/ds.asMatrix.R +++ b/R/ds.asMatrix.R @@ -1,167 +1,73 @@ -#' @title Converts a server-side R object into a matrix -#' @description Coerces an R object into a matrix. -#' This converts all columns into character class. -#' @details This function is based on the native R function \code{as.matrix}. +#' @title Converts a server-side R object into a matrix +#' @description Coerces an R object into a matrix. +#' This converts all columns into character class. +#' @details This function is based on the native R function \code{as.matrix}. #' If this function is applied to a data frame, all columns are converted into a character class. #' If you wish to convert a data frame to a matrix but maintain all data columns in their -#' original class you should use the function \code{ds.asDataMatrix}. -#' +#' original class you should use the function \code{ds.asDataMatrix}. +#' #' Server function called: \code{asMatrixDS} -#' @param x.name a character string providing the name of the input object to be coerced to -#' a matrix. +#' @param x.name a character string providing the name of the input object to be coerced to +#' a matrix. #' @param newobj a character string that provides the name for the output object #' that is stored on the data servers. Default \code{asmatrix.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. -#' @return \code{ds.asMatrix} returns the object converted into a matrix -#' that is written to the server-side. Also, two validity messages are returned -#' to the client-side indicating the name of the \code{newobj} which -#' has been created in each data source and if it is in a valid form. -#' @examples +#' @return \code{ds.asMatrix} returns the object converted into a matrix +#' that is written to the server-side. +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into a matrix #' ds.asMatrix(x.name = "D", #' newobj = "mat.obj", #' datasources = connections[1]) #only the first Opal server is used ("study1") -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } -#' @author DataSHIELD Development Team +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } +#' @author DataSHIELD Development Team #' @export -#' +#' ds.asMatrix <- function(x.name=NULL, newobj=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if(is.null(x.name)){ stop("Please provide the name of the input vector!", call.=FALSE) } - - # check if the input object is defined in all the studies - isDefined(datasources, x.name) - # create a name by default if user did not provide a name for the new variable if(is.null(newobj)){ newobj <- "asmatrix.newobj" } - # call the server side function that does the job - calltext <- call("asMatrixDS", x.name) - DSI::datashield.assign(datasources, newobj, calltext) - - -############################################################################################################# -#DataSHIELD CLIENTSIDE MODULE: CHECK KEY DATA OBJECTS SUCCESSFULLY CREATED # - # -#SET APPROPRIATE PARAMETERS FOR THIS PARTICULAR FUNCTION # -test.obj.name<-newobj # - # # - # -# CALL SEVERSIDE FUNCTION # -calltext <- call("testObjExistsDS", test.obj.name) # - # -object.info<-DSI::datashield.aggregate(datasources, calltext) # - # -# CHECK IN EACH SOURCE WHETHER OBJECT NAME EXISTS # -# AND WHETHER OBJECT PHYSICALLY EXISTS WITH A NON-NULL CLASS # -num.datasources<-length(object.info) # - # - # -obj.name.exists.in.all.sources<-TRUE # -obj.non.null.in.all.sources<-TRUE # - # -for(j in 1:num.datasources){ # - if(!object.info[[j]]$test.obj.exists){ # - obj.name.exists.in.all.sources<-FALSE # - } # - if(is.null(object.info[[j]]$test.obj.class) || ("ABSENT" %in% object.info[[j]]$test.obj.class)){ # - obj.non.null.in.all.sources<-FALSE # - } # - } # - # -if(obj.name.exists.in.all.sources && obj.non.null.in.all.sources){ # - # - return.message<- # - paste0("A data object <", test.obj.name, "> has been created in all specified data sources") # - # - # - }else{ # - # - return.message.1<- # - paste0("Error: A valid data object <", test.obj.name, "> does NOT exist in ALL specified data sources") # - # - return.message.2<- # - paste0("It is either ABSENT and/or has no valid content/class,see return.info above") # - # - return.message.3<- # - paste0("Please use ds.ls() to identify where missing") # - # - # - return.message<-list(return.message.1,return.message.2,return.message.3) # - # - } # - # - calltext <- call("messageDS", test.obj.name) # - studyside.message<-DSI::datashield.aggregate(datasources, calltext) # - # - no.errors<-TRUE # - for(nd in 1:num.datasources){ # - if(studyside.message[[nd]]!="ALL OK: there are no studysideMessage(s) on this datasource"){ # - no.errors<-FALSE # - } # - } # - # - # - if(no.errors){ # - validity.check<-paste0("<",test.obj.name, "> appears valid in all sources") # - return(list(is.object.created=return.message,validity.check=validity.check)) # - } # - # -if(!no.errors){ # - validity.check<-paste0("<",test.obj.name,"> invalid in at least one source. See studyside.messages:") # - return(list(is.object.created=return.message,validity.check=validity.check, # - studyside.messages=studyside.message)) # - } # - # -#END OF CHECK OBJECT CREATED CORECTLY MODULE # -############################################################################################################# - + calltext <- call("asMatrixDS", x.name) + DSI::datashield.assign(datasources, newobj, calltext) } -# ds.asMatrix diff --git a/R/ds.asNumeric.R b/R/ds.asNumeric.R index 3e2b445fa..607161791 100644 --- a/R/ds.asNumeric.R +++ b/R/ds.asNumeric.R @@ -1,179 +1,85 @@ -#' -#' @title Converts a server-side R object into a numeric class -#' @description Coerces an R object into a numeric class. +#' +#' @title Converts a server-side R object into a numeric class +#' @description Coerces an R object into a numeric class. #' This function is based on the native R function \code{as.numeric}. #' @details This function is based on the native R function \code{as.numeric}. -#' However, it behaves differently with some specific classes of variables. For example, if the input +#' However, it behaves differently with some specific classes of variables. For example, if the input #' object is of class factor, it first converts its values into characters and then convert those to #' numerics. This behaviour is important for the case where the input object is of class factor having -#' numbers as levels. In that case, the native R -#' \code{as.numeric} function returns the underlying level codes and not the values as numbers. +#' numbers as levels. In that case, the native R +#' \code{as.numeric} function returns the underlying level codes and not the values as numbers. #' For example \code{as.numeric} in R converts the factor vector: \cr #' 0 1 1 2 1 0 1 0 2 2 2 1 \cr #' Levels: 0 1 2 \cr #' to the following numeric vector: #' 1 2 2 3 2 1 2 1 3 3 3 2 \cr -#' In contrast DataSHIELD converts an input factor with numeric +#' In contrast DataSHIELD converts an input factor with numeric #' levels to its original numeric values. -#' +#' #' Server function called: \code{asNumericDS} -#' -#' @param x.name a character string providing the name of the input object to be coerced to -#' a numeric. +#' +#' @param x.name a character string providing the name of the input object to be coerced to +#' a numeric. #' @param newobj a character string that provides the name for the output object -#' that is stored on the data servers. Default \code{asnumeric.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' that is stored on the data servers. Default \code{asnumeric.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. #' @return \code{ds.asNumeric} returns the R object converted into a numeric class -#' that is written to the server-side. Also, two validity messages are returned -#' to the client-side indicating the name of the \code{newobj} which -#' has been created in each data source and if -#' it is in a valid form. -#' @examples +#' that is written to the server-side. +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into a numeric class #' ds.asNumeric(x.name = "D$LAB_TSC", #' newobj = "num.obj", #' datasources = connections[1]) #only the first Opal server is used ("study1") -#' ds.class(x = "num.obj", datasources = connections[1]) -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } +#' ds.class(x = "num.obj", datasources = connections[1]) +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } #' @author DataSHIELD Development Team #' @export -#' +#' ds.asNumeric <- function(x.name=NULL, newobj=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if(is.null(x.name)){ stop("Please provide the name of the input vector!", call.=FALSE) } - - # check if the input object is defined in all the studies - isDefined(datasources, x.name) - # create a name by default if user did not provide a name for the new variable if(is.null(newobj)){ newobj <- "asnumeric.newobj" } - # call the server side function that does the job calltext <- call("asNumericDS", x.name) DSI::datashield.assign(datasources, newobj, calltext) - -############################################################################################################# -#DataSHIELD CLIENTSIDE MODULE: CHECK KEY DATA OBJECTS SUCCESSFULLY CREATED # - # -#SET APPROPRIATE PARAMETERS FOR THIS PARTICULAR FUNCTION # -test.obj.name<-newobj # - # # - # -# CALL SEVERSIDE FUNCTION # -calltext <- call("testObjExistsDS", test.obj.name) # - # -object.info<-DSI::datashield.aggregate(datasources, calltext) # - # -# CHECK IN EACH SOURCE WHETHER OBJECT NAME EXISTS # -# AND WHETHER OBJECT PHYSICALLY EXISTS WITH A NON-NULL CLASS # -num.datasources<-length(object.info) # - # - # -obj.name.exists.in.all.sources<-TRUE # -obj.non.null.in.all.sources<-TRUE # - # -for(j in 1:num.datasources){ # - if(!object.info[[j]]$test.obj.exists){ # - obj.name.exists.in.all.sources<-FALSE # - } # - if(is.null(object.info[[j]]$test.obj.class) || ("ABSENT" %in% object.info[[j]]$test.obj.class)){ # - obj.non.null.in.all.sources<-FALSE # - } # - } # - # -if(obj.name.exists.in.all.sources && obj.non.null.in.all.sources){ # - # - return.message<- # - paste0("A data object <", test.obj.name, "> has been created in all specified data sources") # - # - # - }else{ # - # - return.message.1<- # - paste0("Error: A valid data object <", test.obj.name, "> does NOT exist in ALL specified data sources") # - # - return.message.2<- # - paste0("It is either ABSENT and/or has no valid content/class,see return.info above") # - # - return.message.3<- # - paste0("Please use ds.ls() to identify where missing") # - # - # - return.message<-list(return.message.1,return.message.2,return.message.3) # - # - } # - # - calltext <- call("messageDS", test.obj.name) # - studyside.message<-DSI::datashield.aggregate(datasources, calltext) # - # - no.errors<-TRUE # - for(nd in 1:num.datasources){ # - if(studyside.message[[nd]]!="ALL OK: there are no studysideMessage(s) on this datasource"){ # - no.errors<-FALSE # - } # - } # - # - # - if(no.errors){ # - validity.check<-paste0("<",test.obj.name, "> appears valid in all sources") # - return(list(is.object.created=return.message,validity.check=validity.check)) # - } # - # -if(!no.errors){ # - validity.check<-paste0("<",test.obj.name,"> invalid in at least one source. See studyside.messages:") # - return(list(is.object.created=return.message,validity.check=validity.check, # - studyside.messages=studyside.message)) # - } # - # -#END OF CHECK OBJECT CREATED CORECTLY MODULE # -############################################################################################################# - } -# ds.asNumeric diff --git a/R/ds.exp.R b/R/ds.exp.R index 5bf325bd8..5e5d64311 100644 --- a/R/ds.exp.R +++ b/R/ds.exp.R @@ -1,98 +1,73 @@ #' #' @title Computes the exponentials in the server-side -#' @description Computes the exponential values for a specified numeric vector. +#' @description Computes the exponential values for a specified numeric vector. #' This function is similar to R function \code{exp}. -#' @details -#' -#' Server function called: \code{exp}. -#' +#' @details +#' +#' Server function called: \code{expDS}. +#' #' @param x a character string providing the name of a numerical vector. #' @param newobj a character string that provides the name for the output variable -#' that is stored on the data servers. Default \code{exp.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. -#' If the \code{datasources} argument is not specified +#' that is stored on the data servers. Default \code{exp.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +#' If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. -#' @return \code{ds.exp} returns a vector for each study of the exponential values for the numeric vector -#' specified in the argument \code{x}. The created vectors are stored in the server-side. +#' @return \code{ds.exp} returns a vector for each study of the exponential values for the numeric vector +#' specified in the argument \code{x}. The created vectors are stored in the server-side. #' @author DataSHIELD Development Team #' @export #' @examples #' \dontrun{ #' -#' ## Version 6, for version 5 see the Wiki +#' ## Version 6, for version 5 see the Wiki #' # Connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') -#' +#' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") -#' +#' #' logindata <- builder$build() -#' +#' #' # Log onto the remote Opal training servers -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # compute exponential function of the 'PM_BMI_CONTINUOUS' variable #' ds.exp(x = "D$PM_BMI_CONTINUOUS", #' newobj = "exp.PM_BMI_CONTINUOUS", #' datasources = connections[1]) #only the first Opal server is used (study1) #' #' # clear the Datashield R sessions and logout -#' datashield.logout(connections) +#' datashield.logout(connections) #' #' } #' ds.exp <- function(x=NULL, newobj=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if(is.null(x)){ stop("Please provide the name of the input object!", call.=FALSE) } - # check if the input object is defined in all the studies - isDefined(datasources, x) - - # call the internal function that checks the input object is of the same class in all studies. - typ <- checkClass(datasources, x) - - # call the internal function that checks the input object(s) is(are) of the same class in all studies. - if(!('numeric' %in% typ) && !('integer' %in% typ)){ - stop(" Only objects of type 'numeric' and 'integer' are allowed.", call.=FALSE) - } - - # create a name by default if user did not provide a name for the new variable if(is.null(newobj)){ newobj <- "exp.newobj" } - # call the server side function that does the job - cally <- paste0('exp(', x, ')') - DSI::datashield.assign(datasources, newobj, as.symbol(cally)) - - - # check that the new object has been created and display a message accordingly - finalcheck <- isAssigned(datasources, newobj) + cally <- call("expDS", x) + DSI::datashield.assign(datasources, newobj, cally) } diff --git a/R/ds.log.R b/R/ds.log.R index 8c0b2e5d2..e5b9d7638 100644 --- a/R/ds.log.R +++ b/R/ds.log.R @@ -1,98 +1,73 @@ #' -#' @title Computes logarithms in the server-side -#' @description Computes the logarithms for a specified numeric vector. -#' This function is similar to the R \code{log} function. by default natural logarithms. -#' @details Server function called: \code{log} +#' @title Computes logarithms in the server-side +#' @description Computes the logarithms for a specified numeric vector. +#' This function is similar to the R \code{log} function. by default natural logarithms. +#' @details Server function called: \code{logDS} #' @param x a character string providing the name of a numerical vector. #' @param base a positive number, the base for which logarithms are computed. #' Default \code{exp(1)}. #' @param newobj a character string that provides the name for the output variable #' that is stored on the server-side. Default \code{log.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. #' If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. -#' @return \code{ds.log} returns a vector for each study of the transformed values for the numeric vector -#' specified in the argument \code{x}. The created vectors are stored in the server-side. +#' @return \code{ds.log} returns a vector for each study of the transformed values for the numeric vector +#' specified in the argument \code{x}. The created vectors are stored in the server-side. #' @author DataSHIELD Development Team #' @export #' @examples #' \dontrun{ -#' -#' ## Version 6, for version 5 see the Wiki +#' +#' ## Version 6, for version 5 see the Wiki #' # Connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') -#' +#' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") -#' +#' #' logindata <- builder$build() -#' +#' #' # Log onto the remote Opal training servers -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Calculating the log value of the 'PM_BMI_CONTINUOUS' variable -#' +#' #' ds.log(x = "D$PM_BMI_CONTINUOUS", #' base = exp(2), #' newobj = "log.PM_BMI_CONTINUOUS", #' datasources = connections[1]) #only the first Opal server is used (study1) #' #' # clear the Datashield R sessions and logout -#' datashield.logout(connections) +#' datashield.logout(connections) #'} #' ds.log <- function(x=NULL, base=exp(1), newobj=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if(is.null(x)){ stop("Please provide the name of the input vector!", call.=FALSE) } - # check if the input object is defined in all the studies - isDefined(datasources, x) - - # call the internal function that checks the input object is of the same class in all studies. - typ <- checkClass(datasources, x) - - # the input object must be a vector - if(!('integer' %in% typ) & !('numeric' %in% typ)){ - message(paste0(x, " is of type ", typ, "!")) - stop("The input object must be an integer or numeric vector.", call.=FALSE) - } - - # create a name by default if user did not provide a name for the new variable if(is.null(newobj)){ newobj <- "log.newobj" } - # call the server side function that does the job - cally <- paste0("log(", x, ",", base, ")") - DSI::datashield.assign(datasources, newobj, as.symbol(cally)) - - # check that the new object has been created and display a message accordingly - finalcheck <- isAssigned(datasources, newobj) + cally <- call("logDS", x, base) + DSI::datashield.assign(datasources, newobj, cally) } diff --git a/R/ds.sqrt.R b/R/ds.sqrt.R index e78011def..3075f36d7 100644 --- a/R/ds.sqrt.R +++ b/R/ds.sqrt.R @@ -1,16 +1,16 @@ #' #' @title Computes the square root values of a variable -#' @description Computes the square root values for a specified numeric or integer vector. +#' @description Computes the square root values for a specified numeric or integer vector. #' This function is similar to R function \code{sqrt}. -#' @details The function calls the server-side function \code{sqrtDS} that computes the -#' square root values of the elements of a numeric or integer vector and assigns a new vector -#' with those square root values on the server-side. The name of the new generated vector is +#' @details The function calls the server-side function \code{sqrtDS} that computes the +#' square root values of the elements of a numeric or integer vector and assigns a new vector +#' with those square root values on the server-side. The name of the new generated vector is #' specified by the user through the argument \code{newobj}, otherwise is named by default to #' \code{sqrt.newobj}. #' @param x a character string providing the name of a numeric or an integer vector. #' @param newobj a character string that provides the name for the output variable -#' that is stored on the data servers. Default name is set to \code{sqrt.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +#' that is stored on the data servers. Default name is set to \code{sqrt.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. #' If the \code{datasources} argument is not specified the default set of connections will be #' used: see \code{\link[DSI]{datashield.connections_default}}. #' @return \code{ds.sqrt} assigns a vector for each study that includes the square root values of @@ -22,34 +22,34 @@ #' \dontrun{ #' #' # Connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') -#' +#' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") -#' +#' #' logindata <- builder$build() -#' +#' #' # Log onto the remote Opal training servers -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Example 1: Get the square root of LAB_HDL variable #' ds.sqrt(x='D$LAB_HDL', newobj='LAB_HDL.sqrt', datasources=connections) #' # compare the mean of LAB_HDL and of LAB_HDL.sqrt -#' # Note here that the number of missing values is bigger in the LAB_HDL.sqrt +#' # Note here that the number of missing values is bigger in the LAB_HDL.sqrt # # vector, because the variable LAB_HDL includes negative values which # # don't have real square roots and those values are returned as NAs. #' ds.mean(x='D$LAB_HDL', datasources=connections) @@ -64,47 +64,23 @@ #' ds.table(rvar='sqrt.vector')$output.list$TABLE_rvar.by.study_counts #' #' # clear the Datashield R sessions and logout -#' datashield.logout(connections) +#' datashield.logout(connections) #' #' } #' ds.sqrt <- function(x=NULL, newobj=NULL, datasources=NULL){ - # look for DS connections - if(is.null(datasources)){ - datasources <- datashield.connections_find() - } - - # ensure datasources is a list of DSConnection-class - if(!(is.list(datasources) && all(unlist(lapply(datasources, function(d) {methods::is(d,"DSConnection")}))))){ - stop("The 'datasources' were expected to be a list of DSConnection-class objects", call.=FALSE) - } + datasources <- .set_datasources(datasources) if(is.null(x)){ stop("Please provide the name of the input object!", call.=FALSE) } - # check if the input object is defined in all the studies - isDefined(datasources, x) - - # call the internal function that checks the input object is of the same class in all studies. - typ <- checkClass(datasources, x) - - # call the internal function that checks the input object(s) is(are) of the same class in all studies. - if(!('numeric' %in% typ) && !('integer' %in% typ)){ - stop("Only objects of type 'numeric' or 'integer' are allowed.", call.=FALSE) - } - - # create a name by default if the user did not provide a name for the new variable if(is.null(newobj)){ newobj <- "sqrt.newobj" } - # call the server side function that does the operation cally <- call("sqrtDS", x) DSI::datashield.assign(datasources, newobj, cally) - # check that the new object has been created and display a message accordingly - finalcheck <- isAssigned(datasources, newobj) - } diff --git a/R/utils.R b/R/utils.R new file mode 100644 index 000000000..85d8d7e2f --- /dev/null +++ b/R/utils.R @@ -0,0 +1,51 @@ +#' Retrieve datasources if not specified +#' +#' @param datasources An optional list of data sources. If not provided, the function will attempt +#' to find available data sources. +#' @importFrom DSI datashield.connections_find +#' @return A list of data sources. +#' @noRd +.get_datasources <- function(datasources) { + if (is.null(datasources)) { + datasources <- datashield.connections_find() + } + return(datasources) +} + +#' Verify that the provided data sources are of class 'DSConnection'. +#' +#' @param datasources A list of data sources. +#' @importFrom cli cli_abort +#' @noRd +.verify_datasources <- function(datasources) { + is_connection_class <- sapply(datasources, function(x) inherits(unlist(x), "DSConnection")) + if (!all(is_connection_class)) { + cli_abort("The 'datasources' were expected to be a list of DSConnection-class objects") + } +} + +#' Set and verify data sources. +#' +#' @param datasources An optional list of data sources. If not provided, the function will attempt +#' to find available data sources. +#' @return A list of verified data sources. +#' @noRd +.set_datasources <- function(datasources) { + datasources <- .get_datasources(datasources) + .verify_datasources(datasources) + return(datasources) +} + +#' Check That a Data Frame Name Is Provided +#' +#' Internal helper that checks whether a data frame or matrix object +#' has been provided. If `NULL`, it aborts with a user-friendly error. +#' +#' @param df A data.frame or matrix. +#' @return Invisibly returns `NULL`. Called for its side effect (error checking). +#' @noRd +.check_df_name_provided <- function(df) { + if(is.null(df)){ + cli_abort("Please provide the name of a data.frame or matrix!", call.=FALSE) + } +} From 9ba87963cb1090d78810a2769fa527e090d653f5 Mon Sep 17 00:00:00 2001 From: Tim Cadman <41470917+timcadman@users.noreply.github.com> Date: Thu, 12 Mar 2026 19:04:43 +0100 Subject: [PATCH 2/7] Update client tests: replace MODULE 5 checks with ds.class verification --- NAMESPACE | 2 + man/ds.abs.Rd | 40 ++++++++--------- man/ds.asCharacter.Rd | 44 +++++++++--------- man/ds.asDataMatrix.Rd | 48 +++++++++----------- man/ds.asInteger.Rd | 55 +++++++++++------------ man/ds.asList.Rd | 48 ++++++++++---------- man/ds.asLogical.Rd | 49 ++++++++++---------- man/ds.asMatrix.Rd | 50 ++++++++++----------- man/ds.asNumeric.Rd | 55 +++++++++++------------ man/ds.exp.Rd | 38 ++++++++-------- man/ds.log.Rd | 38 ++++++++-------- man/ds.sqrt.Rd | 38 ++++++++-------- tests/testthat/test-smk-ds.asCharacter.R | 9 ++-- tests/testthat/test-smk-ds.asDataMatrix.R | 6 +-- tests/testthat/test-smk-ds.asInteger.R | 9 ++-- tests/testthat/test-smk-ds.asLogical.R | 9 ++-- tests/testthat/test-smk-ds.asMatrix.R | 9 ++-- tests/testthat/test-smk-ds.asNumeric.R | 9 ++-- 18 files changed, 270 insertions(+), 286 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 8bdab82e9..bd539a118 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -119,6 +119,8 @@ export(ds.var) export(ds.vectorCalc) import(DSI) import(data.table) +importFrom(DSI,datashield.connections_find) +importFrom(cli,cli_abort) importFrom(stats,as.formula) importFrom(stats,na.omit) importFrom(stats,ts) diff --git a/man/ds.abs.Rd b/man/ds.abs.Rd index 639ebd3e9..9f04d01e2 100644 --- a/man/ds.abs.Rd +++ b/man/ds.abs.Rd @@ -12,7 +12,7 @@ ds.abs(x = NULL, newobj = NULL, datasources = NULL) \item{newobj}{a character string that provides the name for the output variable that is stored on the data servers. Default name is set to \code{abs.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } @@ -22,13 +22,13 @@ the input numeric or integer vector specified in the argument \code{x}. The crea are stored in the servers. } \description{ -Computes the absolute values for a specified numeric or integer vector. +Computes the absolute values for a specified numeric or integer vector. This function is similar to R function \code{abs}. } \details{ -The function calls the server-side function \code{absDS} that computes the -absolute values of the elements of a numeric or integer vector and assigns a new vector -with those absolute values on the server-side. The name of the new generated vector is +The function calls the server-side function \code{absDS} that computes the +absolute values of the elements of a numeric or integer vector and assigns a new vector +with those absolute values on the server-side. The name of the new generated vector is specified by the user through the argument \code{newobj}, otherwise is named by default to \code{abs.newobj}. } @@ -42,24 +42,24 @@ specified by the user through the argument \code{newobj}, otherwise is named by require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") - + logindata <- builder$build() - + # Log onto the remote Opal training servers - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Example 1: Generate a normally distributed variable with zero mean and variance equal # to one and then get their absolute values ds.rNorm(samp.size=100, mean=0, sd=1, newobj='var.norm', datasources=connections) @@ -67,11 +67,11 @@ specified by the user through the argument \code{newobj}, otherwise is named by ds.summary(x='var.norm', datasources=connections) ds.abs(x='var.norm', newobj='var.norm.abs', datasources=connections) # check now the changes in the quantiles - ds.summary(x='var.norm.abs', datasources=connections) + ds.summary(x='var.norm.abs', datasources=connections) # Example 2: Generate a sequence of negative integer numbers from -200 to -100 # and then get their absolute values - ds.seq(FROM.value.char = '-200', TO.value.char = '-100', BY.value.char = '1', + ds.seq(FROM.value.char = '-200', TO.value.char = '-100', BY.value.char = '1', newobj='negative.integers', datasources=connections) # check the quantiles ds.summary(x='negative.integers', datasources=connections) @@ -80,7 +80,7 @@ specified by the user through the argument \code{newobj}, otherwise is named by ds.summary(x='positive.integers', datasources=connections) # clear the Datashield R sessions and logout - datashield.logout(connections) + datashield.logout(connections) } diff --git a/man/ds.asCharacter.Rd b/man/ds.asCharacter.Rd index 447d9cf9e..450b03e7e 100644 --- a/man/ds.asCharacter.Rd +++ b/man/ds.asCharacter.Rd @@ -13,18 +13,16 @@ character.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{ascharacter.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ -\code{ds.asCharacter} returns the object converted into a class character -that is written to the server-side. Also, two validity messages are returned to the client-side -indicating the name of the \code{newobj} which has been created in each data source and if -it is in a valid form. +\code{ds.asCharacter} returns the object converted into a class character +that is written to the server-side. } \description{ -Converts the input object into a character class. +Converts the input object into a character class. This function is based on the native R function \code{as.character}. } \details{ @@ -33,7 +31,7 @@ Server function called: \code{asCharacterDS} \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -41,31 +39,31 @@ Server function called: \code{asCharacterDS} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into a class character ds.asCharacter(x.name = "D$LAB_TSC", newobj = "char.obj", datasources = connections[1]) #only the first Opal server is used ("study1") - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.asDataMatrix.Rd b/man/ds.asDataMatrix.Rd index e6ea9eb9c..81198870e 100644 --- a/man/ds.asDataMatrix.Rd +++ b/man/ds.asDataMatrix.Rd @@ -7,37 +7,33 @@ ds.asDataMatrix(x.name = NULL, newobj = NULL, datasources = NULL) } \arguments{ -\item{x.name}{a character string providing the name of the input object to be coerced to +\item{x.name}{a character string providing the name of the input object to be coerced to a matrix.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{asdatamatrix.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ -\code{ds.asDataMatrix} returns the object converted into a matrix -that is written to the server-side. Also, two validity messages are returned -to the client-side -indicating the name of the \code{newobj} which -has been created in each data source and if -it is in a valid form. +\code{ds.asDataMatrix} returns the object converted into a matrix +that is written to the server-side. } \description{ Coerces an R object into a matrix maintaining original class for all columns in data frames. } \details{ -This function is based on the native R function \code{data.matrix}. +This function is based on the native R function \code{data.matrix}. Server function called: \code{asDataMatrixDS}. } \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -45,31 +41,31 @@ Server function called: \code{asDataMatrixDS}. require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into a matrix ds.asDataMatrix(x.name = "D", newobj = "mat.obj", datasources = connections[1]) #only the first Opal server is used ("study1") - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.asInteger.Rd b/man/ds.asInteger.Rd index d2f0455be..72aaea6ba 100644 --- a/man/ds.asInteger.Rd +++ b/man/ds.asInteger.Rd @@ -7,34 +7,31 @@ ds.asInteger(x.name = NULL, newobj = NULL, datasources = NULL) } \arguments{ -\item{x.name}{a character string providing the name of the input object to be coerced to +\item{x.name}{a character string providing the name of the input object to be coerced to an integer.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{asinteger.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ \code{ds.asInteger} returns the R object converted into an integer -that is written to the server-side. Also, two validity messages are returned to the -client-side indicating the name of the \code{newobj} which -has been created in each data source and if -it is in a valid form. +that is written to the server-side. } \description{ Coerces an R object into an integer class. This function is based on the native R function \code{as.integer}. } \details{ -This function is based on the native R function \code{as.integer}. - The only difference is that the DataSHIELD -function first converts the values of the input object into characters and then convert -those to integers. This addition, +This function is based on the native R function \code{as.integer}. + The only difference is that the DataSHIELD +function first converts the values of the input object into characters and then convert +those to integers. This addition, it is important for the case where the input object is of class -factor having integers as levels. +factor having integers as levels. In that case, the native R \code{as.integer} function returns the underlying level codes and not the values as integers. For example \code{as.integer} in R @@ -49,7 +46,7 @@ Server function called: \code{asIntegerDS} \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -57,32 +54,32 @@ Server function called: \code{asIntegerDS} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into an integer ds.asInteger(x.name = "D$LAB_TSC", newobj = "int.obj", datasources = connections[1]) #only the first Opal server is used ("study1") - ds.class(x = "int.obj", datasources = connections[1]) - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + ds.class(x = "int.obj", datasources = connections[1]) + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.asList.Rd b/man/ds.asList.Rd index 1e2e3c733..bbfb6c9db 100644 --- a/man/ds.asList.Rd +++ b/man/ds.asList.Rd @@ -7,21 +7,19 @@ ds.asList(x.name = NULL, newobj = NULL, datasources = NULL) } \arguments{ -\item{x.name}{a character string providing the name of the input object to be coerced to +\item{x.name}{a character string providing the name of the input object to be coerced to a list.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{aslist.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ -\code{ds.asList} returns the R object converted into a list -which is written to the server-side. Also, two validity messages are returned to the -client-side indicating the name of the \code{newobj} which has been created in each data -source and if it is in a valid form. +\code{ds.asList} returns the R object converted into a list +which is written to the server-side. } \description{ Coerces an R object into a list. @@ -33,7 +31,7 @@ Server function called: \code{asListDS} \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -41,32 +39,32 @@ Server function called: \code{asListDS} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into a List ds.asList(x.name = "D", - newobj = "D.asList", + newobj = "D.asList", datasources = connections[1]) #only the first Opal server is used ("study1") - ds.class(x = "D.asList", datasources = connections[1]) - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + ds.class(x = "D.asList", datasources = connections[1]) + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.asLogical.Rd b/man/ds.asLogical.Rd index c42d2e6aa..9fa8f3d45 100644 --- a/man/ds.asLogical.Rd +++ b/man/ds.asLogical.Rd @@ -7,22 +7,19 @@ ds.asLogical(x.name = NULL, newobj = NULL, datasources = NULL) } \arguments{ -\item{x.name}{a character string providing the name of the +\item{x.name}{a character string providing the name of the input object to be coerced to a logical.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{aslogical.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ \code{ds.asLogical} returns the R object converted into a logical -that is written to the server-side. Also, two validity messages are returned -to the client-side indicating the name of the \code{newobj} which -has been created in each data source and if -it is in a valid form. +that is written to the server-side. } \description{ Coerces an R object into a logical class. @@ -34,7 +31,7 @@ Server function called: \code{asLogicalDS} \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -42,32 +39,32 @@ Server function called: \code{asLogicalDS} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into a logical - ds.asLogical(x.name = "D$LAB_TSC", - newobj = "logical.obj", + ds.asLogical(x.name = "D$LAB_TSC", + newobj = "logical.obj", datasources =connections[1]) #only the first Opal server is used ("study1") - ds.class(x = "logical.obj", datasources = connections[1]) - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + ds.class(x = "logical.obj", datasources = connections[1]) + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.asMatrix.Rd b/man/ds.asMatrix.Rd index 709480148..e16533223 100644 --- a/man/ds.asMatrix.Rd +++ b/man/ds.asMatrix.Rd @@ -7,38 +7,36 @@ ds.asMatrix(x.name = NULL, newobj = NULL, datasources = NULL) } \arguments{ -\item{x.name}{a character string providing the name of the input object to be coerced to +\item{x.name}{a character string providing the name of the input object to be coerced to a matrix.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{asmatrix.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ -\code{ds.asMatrix} returns the object converted into a matrix -that is written to the server-side. Also, two validity messages are returned -to the client-side indicating the name of the \code{newobj} which -has been created in each data source and if it is in a valid form. +\code{ds.asMatrix} returns the object converted into a matrix +that is written to the server-side. } \description{ -Coerces an R object into a matrix. +Coerces an R object into a matrix. This converts all columns into character class. } \details{ -This function is based on the native R function \code{as.matrix}. +This function is based on the native R function \code{as.matrix}. If this function is applied to a data frame, all columns are converted into a character class. If you wish to convert a data frame to a matrix but maintain all data columns in their -original class you should use the function \code{ds.asDataMatrix}. +original class you should use the function \code{ds.asDataMatrix}. Server function called: \code{asMatrixDS} } \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -46,31 +44,31 @@ Server function called: \code{asMatrixDS} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into a matrix ds.asMatrix(x.name = "D", newobj = "mat.obj", datasources = connections[1]) #only the first Opal server is used ("study1") - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.asNumeric.Rd b/man/ds.asNumeric.Rd index 9928942a5..3f7875d93 100644 --- a/man/ds.asNumeric.Rd +++ b/man/ds.asNumeric.Rd @@ -7,40 +7,37 @@ ds.asNumeric(x.name = NULL, newobj = NULL, datasources = NULL) } \arguments{ -\item{x.name}{a character string providing the name of the input object to be coerced to +\item{x.name}{a character string providing the name of the input object to be coerced to a numeric.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{asnumeric.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ \code{ds.asNumeric} returns the R object converted into a numeric class -that is written to the server-side. Also, two validity messages are returned -to the client-side indicating the name of the \code{newobj} which -has been created in each data source and if -it is in a valid form. +that is written to the server-side. } \description{ -Coerces an R object into a numeric class. +Coerces an R object into a numeric class. This function is based on the native R function \code{as.numeric}. } \details{ This function is based on the native R function \code{as.numeric}. -However, it behaves differently with some specific classes of variables. For example, if the input +However, it behaves differently with some specific classes of variables. For example, if the input object is of class factor, it first converts its values into characters and then convert those to numerics. This behaviour is important for the case where the input object is of class factor having -numbers as levels. In that case, the native R -\code{as.numeric} function returns the underlying level codes and not the values as numbers. +numbers as levels. In that case, the native R +\code{as.numeric} function returns the underlying level codes and not the values as numbers. For example \code{as.numeric} in R converts the factor vector: \cr 0 1 1 2 1 0 1 0 2 2 2 1 \cr Levels: 0 1 2 \cr to the following numeric vector: 1 2 2 3 2 1 2 1 3 3 3 2 \cr -In contrast DataSHIELD converts an input factor with numeric +In contrast DataSHIELD converts an input factor with numeric levels to its original numeric values. Server function called: \code{asNumericDS} @@ -48,7 +45,7 @@ Server function called: \code{asNumericDS} \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -56,32 +53,32 @@ Server function called: \code{asNumericDS} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into a numeric class ds.asNumeric(x.name = "D$LAB_TSC", newobj = "num.obj", datasources = connections[1]) #only the first Opal server is used ("study1") - ds.class(x = "num.obj", datasources = connections[1]) - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + ds.class(x = "num.obj", datasources = connections[1]) + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.exp.Rd b/man/ds.exp.Rd index 875dbe00e..4e45692cf 100644 --- a/man/ds.exp.Rd +++ b/man/ds.exp.Rd @@ -12,25 +12,25 @@ ds.exp(x = NULL, newobj = NULL, datasources = NULL) \item{newobj}{a character string that provides the name for the output variable that is stored on the data servers. Default \code{exp.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. -If the \code{datasources} argument is not specified +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ -\code{ds.exp} returns a vector for each study of the exponential values for the numeric vector +\code{ds.exp} returns a vector for each study of the exponential values for the numeric vector specified in the argument \code{x}. The created vectors are stored in the server-side. } \description{ -Computes the exponential values for a specified numeric vector. +Computes the exponential values for a specified numeric vector. This function is similar to R function \code{exp}. } \details{ -Server function called: \code{exp}. +Server function called: \code{expDS}. } \examples{ \dontrun{ - ## Version 6, for version 5 see the Wiki + ## Version 6, for version 5 see the Wiki # Connecting to the Opal servers require('DSI') @@ -38,31 +38,31 @@ Server function called: \code{exp}. require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") - + logindata <- builder$build() - + # Log onto the remote Opal training servers - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # compute exponential function of the 'PM_BMI_CONTINUOUS' variable ds.exp(x = "D$PM_BMI_CONTINUOUS", newobj = "exp.PM_BMI_CONTINUOUS", datasources = connections[1]) #only the first Opal server is used (study1) # clear the Datashield R sessions and logout - datashield.logout(connections) + datashield.logout(connections) } diff --git a/man/ds.log.Rd b/man/ds.log.Rd index 6ab8fee72..bbe9cadfa 100644 --- a/man/ds.log.Rd +++ b/man/ds.log.Rd @@ -15,25 +15,25 @@ Default \code{exp(1)}.} \item{newobj}{a character string that provides the name for the output variable that is stored on the server-side. Default \code{log.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ -\code{ds.log} returns a vector for each study of the transformed values for the numeric vector +\code{ds.log} returns a vector for each study of the transformed values for the numeric vector specified in the argument \code{x}. The created vectors are stored in the server-side. } \description{ -Computes the logarithms for a specified numeric vector. +Computes the logarithms for a specified numeric vector. This function is similar to the R \code{log} function. by default natural logarithms. } \details{ -Server function called: \code{log} +Server function called: \code{logDS} } \examples{ \dontrun{ - ## Version 6, for version 5 see the Wiki + ## Version 6, for version 5 see the Wiki # Connecting to the Opal servers require('DSI') @@ -41,33 +41,33 @@ Server function called: \code{log} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") - + logindata <- builder$build() - + # Log onto the remote Opal training servers - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Calculating the log value of the 'PM_BMI_CONTINUOUS' variable - + ds.log(x = "D$PM_BMI_CONTINUOUS", base = exp(2), newobj = "log.PM_BMI_CONTINUOUS", datasources = connections[1]) #only the first Opal server is used (study1) # clear the Datashield R sessions and logout - datashield.logout(connections) + datashield.logout(connections) } } diff --git a/man/ds.sqrt.Rd b/man/ds.sqrt.Rd index 638d26a5f..90120ab27 100644 --- a/man/ds.sqrt.Rd +++ b/man/ds.sqrt.Rd @@ -12,7 +12,7 @@ ds.sqrt(x = NULL, newobj = NULL, datasources = NULL) \item{newobj}{a character string that provides the name for the output variable that is stored on the data servers. Default name is set to \code{sqrt.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } @@ -22,13 +22,13 @@ the input numeric or integer vector specified in the argument \code{x}. The crea are stored in the servers. } \description{ -Computes the square root values for a specified numeric or integer vector. +Computes the square root values for a specified numeric or integer vector. This function is similar to R function \code{sqrt}. } \details{ -The function calls the server-side function \code{sqrtDS} that computes the -square root values of the elements of a numeric or integer vector and assigns a new vector -with those square root values on the server-side. The name of the new generated vector is +The function calls the server-side function \code{sqrtDS} that computes the +square root values of the elements of a numeric or integer vector and assigns a new vector +with those square root values on the server-side. The name of the new generated vector is specified by the user through the argument \code{newobj}, otherwise is named by default to \code{sqrt.newobj}. } @@ -42,28 +42,28 @@ specified by the user through the argument \code{newobj}, otherwise is named by require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") - + logindata <- builder$build() - + # Log onto the remote Opal training servers - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Example 1: Get the square root of LAB_HDL variable ds.sqrt(x='D$LAB_HDL', newobj='LAB_HDL.sqrt', datasources=connections) # compare the mean of LAB_HDL and of LAB_HDL.sqrt - # Note here that the number of missing values is bigger in the LAB_HDL.sqrt + # Note here that the number of missing values is bigger in the LAB_HDL.sqrt ds.mean(x='D$LAB_HDL', datasources=connections) ds.mean(x='LAB_HDL.sqrt', datasources=connections) @@ -75,7 +75,7 @@ specified by the user through the argument \code{newobj}, otherwise is named by ds.table(rvar='sqrt.vector')$output.list$TABLE_rvar.by.study_counts # clear the Datashield R sessions and logout - datashield.logout(connections) + datashield.logout(connections) } diff --git a/tests/testthat/test-smk-ds.asCharacter.R b/tests/testthat/test-smk-ds.asCharacter.R index ae8b7e60c..07d633b6c 100644 --- a/tests/testthat/test-smk-ds.asCharacter.R +++ b/tests/testthat/test-smk-ds.asCharacter.R @@ -27,11 +27,12 @@ test_that("setup", { # context("ds.asCharacter::smk::simple test") test_that("simple test", { - res <- ds.asCharacter("D$LAB_TSC") + ds.asCharacter("D$LAB_TSC") - expect_equal(length(res), 2) - expect_equal(res$is.object.created, "A data object has been created in all specified data sources") - expect_equal(res$validity.check, " appears valid in all sources") + res.class <- ds.class("ascharacter.newobj") + expect_equal(res.class$sim1, "character") + expect_equal(res.class$sim2, "character") + expect_equal(res.class$sim3, "character") }) # diff --git a/tests/testthat/test-smk-ds.asDataMatrix.R b/tests/testthat/test-smk-ds.asDataMatrix.R index 25ef3736a..4f4217251 100644 --- a/tests/testthat/test-smk-ds.asDataMatrix.R +++ b/tests/testthat/test-smk-ds.asDataMatrix.R @@ -27,11 +27,7 @@ test_that("setup", { # context("ds.asDataMatrix::smk::simple test") test_that("simple test", { - res <- ds.asDataMatrix(x.name="D$GENDER") - - expect_length(res, 2) - expect_equal(res$is.object.created, "A data object has been created in all specified data sources") - expect_equal(res$validity.check, " appears valid in all sources") + ds.asDataMatrix(x.name="D$GENDER") res.class <- ds.class("asdatamatrix.newobj") expect_length(res.class, 3) diff --git a/tests/testthat/test-smk-ds.asInteger.R b/tests/testthat/test-smk-ds.asInteger.R index 1ef25fbf0..0045cb80c 100644 --- a/tests/testthat/test-smk-ds.asInteger.R +++ b/tests/testthat/test-smk-ds.asInteger.R @@ -27,11 +27,12 @@ test_that("setup", { # context("ds.asInteger::smk::simple test") test_that("simple test", { - res <- ds.asInteger("D$GENDER") + ds.asInteger("D$GENDER") - expect_equal(length(res), 2) - expect_equal(res$is.object.created, "A data object has been created in all specified data sources") - expect_equal(res$validity.check, " appears valid in all sources") + res.class <- ds.class("asinteger.newobj") + expect_equal(res.class$sim1, "integer") + expect_equal(res.class$sim2, "integer") + expect_equal(res.class$sim3, "integer") }) # diff --git a/tests/testthat/test-smk-ds.asLogical.R b/tests/testthat/test-smk-ds.asLogical.R index 6781beab6..6e31ecce1 100644 --- a/tests/testthat/test-smk-ds.asLogical.R +++ b/tests/testthat/test-smk-ds.asLogical.R @@ -27,11 +27,12 @@ test_that("setup", { # context("ds.asLogical::smk::simple test") test_that("simple test", { - res <- ds.asLogical("D$LAB_TSC") + ds.asLogical("D$LAB_TSC") - expect_equal(length(res), 2) - expect_equal(res$is.object.created, "A data object has been created in all specified data sources") - expect_equal(res$validity.check, " appears valid in all sources") + res.class <- ds.class("aslogical.newobj") + expect_equal(res.class$sim1, "logical") + expect_equal(res.class$sim2, "logical") + expect_equal(res.class$sim3, "logical") }) # diff --git a/tests/testthat/test-smk-ds.asMatrix.R b/tests/testthat/test-smk-ds.asMatrix.R index b942425b7..b17066c2a 100644 --- a/tests/testthat/test-smk-ds.asMatrix.R +++ b/tests/testthat/test-smk-ds.asMatrix.R @@ -27,11 +27,12 @@ test_that("setup", { # context("ds.asMatrix::smk::simple test") test_that("simple test", { - res <- ds.asMatrix(x.name="D$GENDER") + ds.asMatrix(x.name="D$GENDER") - expect_length(res, 2) - expect_equal(res$is.object.created, "A data object has been created in all specified data sources") - expect_equal(res$validity.check, " appears valid in all sources") + res.class <- ds.class("asmatrix.newobj") + expect_true("matrix" %in% res.class$sim1) + expect_true("matrix" %in% res.class$sim2) + expect_true("matrix" %in% res.class$sim3) }) # diff --git a/tests/testthat/test-smk-ds.asNumeric.R b/tests/testthat/test-smk-ds.asNumeric.R index e942c82af..aa2fdf2f1 100644 --- a/tests/testthat/test-smk-ds.asNumeric.R +++ b/tests/testthat/test-smk-ds.asNumeric.R @@ -27,11 +27,12 @@ test_that("setup", { # context("ds.asNumeric::smk::simple test") test_that("simple test", { - res <- ds.asNumeric("D$GENDER") + ds.asNumeric("D$GENDER") - expect_equal(length(res), 2) - expect_equal(res$is.object.created, "A data object has been created in all specified data sources") - expect_equal(res$validity.check, " appears valid in all sources") + res.class <- ds.class("asnumeric.newobj") + expect_equal(res.class$sim1, "numeric") + expect_equal(res.class$sim2, "numeric") + expect_equal(res.class$sim3, "numeric") }) # From 92c58ff680c4f92a5462147fff4a41b9433ff62d Mon Sep 17 00:00:00 2001 From: Tim Cadman <41470917+timcadman@users.noreply.github.com> Date: Fri, 13 Mar 2026 11:51:34 +0100 Subject: [PATCH 3/7] revert whitespace changes --- R/ds.abs.R | 46 +++++++++++++-------------- R/ds.asCharacter.R | 60 ++++++++++++++++++------------------ R/ds.asDataMatrix.R | 62 ++++++++++++++++++------------------- R/ds.asInteger.R | 68 ++++++++++++++++++++-------------------- R/ds.asList.R | 60 ++++++++++++++++++------------------ R/ds.asLogical.R | 68 ++++++++++++++++++++-------------------- R/ds.asMatrix.R | 68 ++++++++++++++++++++-------------------- R/ds.asNumeric.R | 70 +++++++++++++++++++++--------------------- R/ds.exp.R | 50 +++++++++++++++--------------- R/ds.log.R | 48 ++++++++++++++--------------- R/ds.sqrt.R | 44 +++++++++++++------------- man/ds.abs.Rd | 40 ++++++++++++------------ man/ds.asCharacter.Rd | 40 ++++++++++++------------ man/ds.asDataMatrix.Rd | 42 ++++++++++++------------- man/ds.asInteger.Rd | 50 +++++++++++++++--------------- man/ds.asList.Rd | 44 +++++++++++++------------- man/ds.asLogical.Rd | 44 +++++++++++++------------- man/ds.asMatrix.Rd | 46 +++++++++++++-------------- man/ds.asNumeric.Rd | 50 +++++++++++++++--------------- man/ds.exp.Rd | 36 +++++++++++----------- man/ds.log.Rd | 36 +++++++++++----------- man/ds.sqrt.Rd | 38 +++++++++++------------ 22 files changed, 555 insertions(+), 555 deletions(-) diff --git a/R/ds.abs.R b/R/ds.abs.R index 3a27b20ad..22c16648d 100644 --- a/R/ds.abs.R +++ b/R/ds.abs.R @@ -1,16 +1,16 @@ #' #' @title Computes the absolute values of a variable -#' @description Computes the absolute values for a specified numeric or integer vector. +#' @description Computes the absolute values for a specified numeric or integer vector. #' This function is similar to R function \code{abs}. -#' @details The function calls the server-side function \code{absDS} that computes the -#' absolute values of the elements of a numeric or integer vector and assigns a new vector -#' with those absolute values on the server-side. The name of the new generated vector is +#' @details The function calls the server-side function \code{absDS} that computes the +#' absolute values of the elements of a numeric or integer vector and assigns a new vector +#' with those absolute values on the server-side. The name of the new generated vector is #' specified by the user through the argument \code{newobj}, otherwise is named by default to #' \code{abs.newobj}. #' @param x a character string providing the name of a numeric or an integer vector. #' @param newobj a character string that provides the name for the output variable -#' that is stored on the data servers. Default name is set to \code{abs.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +#' that is stored on the data servers. Default name is set to \code{abs.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. #' If the \code{datasources} argument is not specified the default set of connections will be #' used: see \code{\link[DSI]{datashield.connections_default}}. #' @return \code{ds.abs} assigns a vector for each study that includes the absolute values of @@ -22,30 +22,30 @@ #' \dontrun{ #' #' # Connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') -#' +#' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") -#' +#' #' logindata <- builder$build() -#' +#' #' # Log onto the remote Opal training servers -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Example 1: Generate a normally distributed variable with zero mean and variance equal #' # to one and then get their absolute values #' ds.rNorm(samp.size=100, mean=0, sd=1, newobj='var.norm', datasources=connections) @@ -53,11 +53,11 @@ #' ds.summary(x='var.norm', datasources=connections) #' ds.abs(x='var.norm', newobj='var.norm.abs', datasources=connections) #' # check now the changes in the quantiles -#' ds.summary(x='var.norm.abs', datasources=connections) +#' ds.summary(x='var.norm.abs', datasources=connections) #' #' # Example 2: Generate a sequence of negative integer numbers from -200 to -100 #' # and then get their absolute values -#' ds.seq(FROM.value.char = '-200', TO.value.char = '-100', BY.value.char = '1', +#' ds.seq(FROM.value.char = '-200', TO.value.char = '-100', BY.value.char = '1', #' newobj='negative.integers', datasources=connections) #' # check the quantiles #' ds.summary(x='negative.integers', datasources=connections) @@ -66,7 +66,7 @@ #' ds.summary(x='positive.integers', datasources=connections) #' #' # clear the Datashield R sessions and logout -#' datashield.logout(connections) +#' datashield.logout(connections) #' #' } #' diff --git a/R/ds.asCharacter.R b/R/ds.asCharacter.R index d349a6cc2..60b9d20af 100644 --- a/R/ds.asCharacter.R +++ b/R/ds.asCharacter.R @@ -1,58 +1,58 @@ -#' +#' #' @title Converts a server-side R object into a character class -#' @description Converts the input object into a character class. +#' @description Converts the input object into a character class. #' This function is based on the native R function \code{as.character}. -#' @details +#' @details #' Server function called: \code{asCharacterDS} -#' +#' #' @param x.name a character string providing the name of the input object to be coerced to class #' character. #' @param newobj a character string that provides the name for the output object -#' that is stored on the data servers. Default \code{ascharacter.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' that is stored on the data servers. Default \code{ascharacter.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. -#' @return \code{ds.asCharacter} returns the object converted into a class character +#' @return \code{ds.asCharacter} returns the object converted into a class character #' that is written to the server-side. -#' @examples +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into a class character #' ds.asCharacter(x.name = "D$LAB_TSC", #' newobj = "char.obj", #' datasources = connections[1]) #only the first Opal server is used ("study1") -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } #' @author DataSHIELD Development Team #' @export -#' +#' ds.asCharacter <- function(x.name=NULL, newobj=NULL, datasources=NULL){ datasources <- .set_datasources(datasources) @@ -60,12 +60,12 @@ ds.asCharacter <- function(x.name=NULL, newobj=NULL, datasources=NULL){ if(is.null(x.name)){ stop("Please provide the name of the input vector!", call.=FALSE) } - + if(is.null(newobj)){ newobj <- "ascharacter.newobj" } - calltext <- call("asCharacterDS", x.name) - DSI::datashield.assign(datasources, newobj, calltext) + calltext <- call("asCharacterDS", x.name) + DSI::datashield.assign(datasources, newobj, calltext) } diff --git a/R/ds.asDataMatrix.R b/R/ds.asDataMatrix.R index 976986dbe..d705dc956 100644 --- a/R/ds.asDataMatrix.R +++ b/R/ds.asDataMatrix.R @@ -1,57 +1,57 @@ -#' @title Converts a server-side R object into a matrix +#' @title Converts a server-side R object into a matrix #' @description Coerces an R object into a matrix maintaining original -#' class for all columns in data frames. -#' @details This function is based on the native R function \code{data.matrix}. -#' +#' class for all columns in data frames. +#' @details This function is based on the native R function \code{data.matrix}. +#' #' Server function called: \code{asDataMatrixDS}. -#' @param x.name a character string providing the name of the input object to be coerced to -#' a matrix. +#' @param x.name a character string providing the name of the input object to be coerced to +#' a matrix. #' @param newobj a character string that provides the name for the output object #' that is stored on the data servers. Default \code{asdatamatrix.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. -#' @return \code{ds.asDataMatrix} returns the object converted into a matrix +#' @return \code{ds.asDataMatrix} returns the object converted into a matrix #' that is written to the server-side. -#' @examples +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into a matrix #' ds.asDataMatrix(x.name = "D", #' newobj = "mat.obj", #' datasources = connections[1]) #only the first Opal server is used ("study1") -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } #' @author DataSHIELD Development Team #' @export -#' +#' ds.asDataMatrix <- function(x.name=NULL, newobj=NULL, datasources=NULL){ datasources <- .set_datasources(datasources) @@ -59,12 +59,12 @@ ds.asDataMatrix <- function(x.name=NULL, newobj=NULL, datasources=NULL){ if(is.null(x.name)){ stop("Please provide the name of the input vector!", call.=FALSE) } - + if(is.null(newobj)){ newobj <- "asdatamatrix.newobj" } - calltext <- call("asDataMatrixDS", x.name) - DSI::datashield.assign(datasources, newobj, calltext) + calltext <- call("asDataMatrixDS", x.name) + DSI::datashield.assign(datasources, newobj, calltext) } diff --git a/R/ds.asInteger.R b/R/ds.asInteger.R index 33d1bb82f..da5117aa8 100644 --- a/R/ds.asInteger.R +++ b/R/ds.asInteger.R @@ -1,12 +1,12 @@ -#' @title Converts a server-side R object into an integer class +#' @title Converts a server-side R object into an integer class #' @description Coerces an R object into an integer class. #' This function is based on the native R function \code{as.integer}. -#' @details This function is based on the native R function \code{as.integer}. -#' The only difference is that the DataSHIELD -#' function first converts the values of the input object into characters and then convert -#' those to integers. This addition, +#' @details This function is based on the native R function \code{as.integer}. +#' The only difference is that the DataSHIELD +#' function first converts the values of the input object into characters and then convert +#' those to integers. This addition, #' it is important for the case where the input object is of class -#' factor having integers as levels. +#' factor having integers as levels. #' In that case, the native R \code{as.integer} function returns #' the underlying level codes and not the values as integers. #' For example \code{as.integer} in R @@ -15,65 +15,65 @@ #' Levels: 0 1 2 \cr #' to the following integer vector: #' 1 2 2 3 2 1 2 1 3 3 3 2 \cr -#' +#' #' Server function called: \code{asIntegerDS} -#' -#' @param x.name a character string providing the name of the input object to be coerced to -#' an integer. +#' +#' @param x.name a character string providing the name of the input object to be coerced to +#' an integer. #' @param newobj a character string that provides the name for the output object -#' that is stored on the data servers. Default \code{asinteger.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' that is stored on the data servers. Default \code{asinteger.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. #' @return \code{ds.asInteger} returns the R object converted into an integer #' that is written to the server-side. -#' @examples +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into an integer #' ds.asInteger(x.name = "D$LAB_TSC", #' newobj = "int.obj", #' datasources = connections[1]) #only the first Opal server is used ("study1") -#' ds.class(x = "int.obj", datasources = connections[1]) -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } +#' ds.class(x = "int.obj", datasources = connections[1]) +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } #' @author DataSHIELD Development Team #' @export ds.asInteger <- function(x.name=NULL, newobj=NULL, datasources=NULL){ - + datasources <- .set_datasources(datasources) if(is.null(x.name)){ stop("Please provide the name of the input vector!", call.=FALSE) } - + if(is.null(newobj)){ newobj <- "asinteger.newobj" } diff --git a/R/ds.asList.R b/R/ds.asList.R index 8338cf274..5c869d34f 100644 --- a/R/ds.asList.R +++ b/R/ds.asList.R @@ -1,59 +1,59 @@ -#' -#' @title Converts a server-side R object into a list +#' +#' @title Converts a server-side R object into a list #' @description Coerces an R object into a list. #' This function is based on the native R function \code{as.list}. -#' @details -#' +#' @details +#' #' Server function called: \code{asListDS} -#' @param x.name a character string providing the name of the input object to be coerced to +#' @param x.name a character string providing the name of the input object to be coerced to #' a list. #' @param newobj a character string that provides the name for the output object -#' that is stored on the data servers. Default \code{aslist.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' that is stored on the data servers. Default \code{aslist.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. -#' @return \code{ds.asList} returns the R object converted into a list +#' @return \code{ds.asList} returns the R object converted into a list #' which is written to the server-side. -#' @examples +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into a List #' ds.asList(x.name = "D", -#' newobj = "D.asList", +#' newobj = "D.asList", #' datasources = connections[1]) #only the first Opal server is used ("study1") -#' ds.class(x = "D.asList", datasources = connections[1]) -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } +#' ds.class(x = "D.asList", datasources = connections[1]) +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } #' @author DataSHIELD Development Team #' @export -#' +#' ds.asList <- function(x.name=NULL, newobj=NULL, datasources=NULL){ datasources <- .set_datasources(datasources) diff --git a/R/ds.asLogical.R b/R/ds.asLogical.R index 3fb2ae0d0..ca3fec8ca 100644 --- a/R/ds.asLogical.R +++ b/R/ds.asLogical.R @@ -1,58 +1,58 @@ -#' @title Converts a server-side R object into a logical class +#' @title Converts a server-side R object into a logical class #' @description Coerces an R object into a logical class. -#' This function is based on the native R function \code{as.logical}. -#' @details -#' +#' This function is based on the native R function \code{as.logical}. +#' @details +#' #' Server function called: \code{asLogicalDS} -#' @param x.name a character string providing the name of the -#' input object to be coerced to a logical. +#' @param x.name a character string providing the name of the +#' input object to be coerced to a logical. #' @param newobj a character string that provides the name for the output object -#' that is stored on the data servers. Default \code{aslogical.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' that is stored on the data servers. Default \code{aslogical.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. #' @return \code{ds.asLogical} returns the R object converted into a logical #' that is written to the server-side. -#' @examples +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into a logical -#' ds.asLogical(x.name = "D$LAB_TSC", -#' newobj = "logical.obj", +#' ds.asLogical(x.name = "D$LAB_TSC", +#' newobj = "logical.obj", #' datasources =connections[1]) #only the first Opal server is used ("study1") -#' ds.class(x = "logical.obj", datasources = connections[1]) -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } +#' ds.class(x = "logical.obj", datasources = connections[1]) +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } #' @author DataSHIELD Development Team #' @export -#' +#' ds.asLogical <- function(x.name=NULL, newobj=NULL, datasources=NULL){ datasources <- .set_datasources(datasources) @@ -60,12 +60,12 @@ ds.asLogical <- function(x.name=NULL, newobj=NULL, datasources=NULL){ if(is.null(x.name)){ stop("Please provide the name of the input vector!", call.=FALSE) } - + if(is.null(newobj)){ newobj <- "aslogical.newobj" } - calltext <- call("asLogicalDS", x.name) - DSI::datashield.assign(datasources, newobj, calltext) + calltext <- call("asLogicalDS", x.name) + DSI::datashield.assign(datasources, newobj, calltext) } diff --git a/R/ds.asMatrix.R b/R/ds.asMatrix.R index 141b58c1d..0adcb9693 100644 --- a/R/ds.asMatrix.R +++ b/R/ds.asMatrix.R @@ -1,60 +1,60 @@ -#' @title Converts a server-side R object into a matrix -#' @description Coerces an R object into a matrix. -#' This converts all columns into character class. -#' @details This function is based on the native R function \code{as.matrix}. +#' @title Converts a server-side R object into a matrix +#' @description Coerces an R object into a matrix. +#' This converts all columns into character class. +#' @details This function is based on the native R function \code{as.matrix}. #' If this function is applied to a data frame, all columns are converted into a character class. #' If you wish to convert a data frame to a matrix but maintain all data columns in their -#' original class you should use the function \code{ds.asDataMatrix}. -#' +#' original class you should use the function \code{ds.asDataMatrix}. +#' #' Server function called: \code{asMatrixDS} -#' @param x.name a character string providing the name of the input object to be coerced to -#' a matrix. +#' @param x.name a character string providing the name of the input object to be coerced to +#' a matrix. #' @param newobj a character string that provides the name for the output object #' that is stored on the data servers. Default \code{asmatrix.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. -#' @return \code{ds.asMatrix} returns the object converted into a matrix +#' @return \code{ds.asMatrix} returns the object converted into a matrix #' that is written to the server-side. -#' @examples +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into a matrix #' ds.asMatrix(x.name = "D", #' newobj = "mat.obj", #' datasources = connections[1]) #only the first Opal server is used ("study1") -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } -#' @author DataSHIELD Development Team +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } +#' @author DataSHIELD Development Team #' @export -#' +#' ds.asMatrix <- function(x.name=NULL, newobj=NULL, datasources=NULL){ datasources <- .set_datasources(datasources) @@ -62,12 +62,12 @@ ds.asMatrix <- function(x.name=NULL, newobj=NULL, datasources=NULL){ if(is.null(x.name)){ stop("Please provide the name of the input vector!", call.=FALSE) } - + if(is.null(newobj)){ newobj <- "asmatrix.newobj" } - calltext <- call("asMatrixDS", x.name) - DSI::datashield.assign(datasources, newobj, calltext) + calltext <- call("asMatrixDS", x.name) + DSI::datashield.assign(datasources, newobj, calltext) } diff --git a/R/ds.asNumeric.R b/R/ds.asNumeric.R index 607161791..2067bb53b 100644 --- a/R/ds.asNumeric.R +++ b/R/ds.asNumeric.R @@ -1,72 +1,72 @@ -#' -#' @title Converts a server-side R object into a numeric class -#' @description Coerces an R object into a numeric class. +#' +#' @title Converts a server-side R object into a numeric class +#' @description Coerces an R object into a numeric class. #' This function is based on the native R function \code{as.numeric}. #' @details This function is based on the native R function \code{as.numeric}. -#' However, it behaves differently with some specific classes of variables. For example, if the input +#' However, it behaves differently with some specific classes of variables. For example, if the input #' object is of class factor, it first converts its values into characters and then convert those to #' numerics. This behaviour is important for the case where the input object is of class factor having -#' numbers as levels. In that case, the native R -#' \code{as.numeric} function returns the underlying level codes and not the values as numbers. +#' numbers as levels. In that case, the native R +#' \code{as.numeric} function returns the underlying level codes and not the values as numbers. #' For example \code{as.numeric} in R converts the factor vector: \cr #' 0 1 1 2 1 0 1 0 2 2 2 1 \cr #' Levels: 0 1 2 \cr #' to the following numeric vector: #' 1 2 2 3 2 1 2 1 3 3 3 2 \cr -#' In contrast DataSHIELD converts an input factor with numeric +#' In contrast DataSHIELD converts an input factor with numeric #' levels to its original numeric values. -#' +#' #' Server function called: \code{asNumericDS} -#' -#' @param x.name a character string providing the name of the input object to be coerced to -#' a numeric. +#' +#' @param x.name a character string providing the name of the input object to be coerced to +#' a numeric. #' @param newobj a character string that provides the name for the output object -#' that is stored on the data servers. Default \code{asnumeric.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} +#' that is stored on the data servers. Default \code{asnumeric.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} #' objects obtained after login. If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. #' @return \code{ds.asNumeric} returns the R object converted into a numeric class #' that is written to the server-side. -#' @examples +#' @examples #' \dontrun{ #' ## Version 6, for version 5 see the Wiki -#' +#' #' # connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') #' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") #' logindata <- builder$build() -#' -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Converting the R object into a numeric class #' ds.asNumeric(x.name = "D$LAB_TSC", #' newobj = "num.obj", #' datasources = connections[1]) #only the first Opal server is used ("study1") -#' ds.class(x = "num.obj", datasources = connections[1]) -#' -#' # Clear the Datashield R sessions and logout -#' datashield.logout(connections) -#' -#' } +#' ds.class(x = "num.obj", datasources = connections[1]) +#' +#' # Clear the Datashield R sessions and logout +#' datashield.logout(connections) +#' +#' } #' @author DataSHIELD Development Team #' @export -#' +#' ds.asNumeric <- function(x.name=NULL, newobj=NULL, datasources=NULL){ datasources <- .set_datasources(datasources) @@ -74,7 +74,7 @@ ds.asNumeric <- function(x.name=NULL, newobj=NULL, datasources=NULL){ if(is.null(x.name)){ stop("Please provide the name of the input vector!", call.=FALSE) } - + if(is.null(newobj)){ newobj <- "asnumeric.newobj" } diff --git a/R/ds.exp.R b/R/ds.exp.R index 5e5d64311..03454aedb 100644 --- a/R/ds.exp.R +++ b/R/ds.exp.R @@ -1,57 +1,57 @@ #' #' @title Computes the exponentials in the server-side -#' @description Computes the exponential values for a specified numeric vector. +#' @description Computes the exponential values for a specified numeric vector. #' This function is similar to R function \code{exp}. -#' @details -#' +#' @details +#' #' Server function called: \code{expDS}. -#' +#' #' @param x a character string providing the name of a numerical vector. #' @param newobj a character string that provides the name for the output variable -#' that is stored on the data servers. Default \code{exp.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. -#' If the \code{datasources} argument is not specified +#' that is stored on the data servers. Default \code{exp.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +#' If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. -#' @return \code{ds.exp} returns a vector for each study of the exponential values for the numeric vector -#' specified in the argument \code{x}. The created vectors are stored in the server-side. +#' @return \code{ds.exp} returns a vector for each study of the exponential values for the numeric vector +#' specified in the argument \code{x}. The created vectors are stored in the server-side. #' @author DataSHIELD Development Team #' @export #' @examples #' \dontrun{ #' -#' ## Version 6, for version 5 see the Wiki +#' ## Version 6, for version 5 see the Wiki #' # Connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') -#' +#' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") -#' +#' #' logindata <- builder$build() -#' +#' #' # Log onto the remote Opal training servers -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # compute exponential function of the 'PM_BMI_CONTINUOUS' variable #' ds.exp(x = "D$PM_BMI_CONTINUOUS", #' newobj = "exp.PM_BMI_CONTINUOUS", #' datasources = connections[1]) #only the first Opal server is used (study1) #' #' # clear the Datashield R sessions and logout -#' datashield.logout(connections) +#' datashield.logout(connections) #' #' } #' diff --git a/R/ds.log.R b/R/ds.log.R index e5b9d7638..4e5b13f3f 100644 --- a/R/ds.log.R +++ b/R/ds.log.R @@ -1,58 +1,58 @@ #' -#' @title Computes logarithms in the server-side -#' @description Computes the logarithms for a specified numeric vector. -#' This function is similar to the R \code{log} function. by default natural logarithms. +#' @title Computes logarithms in the server-side +#' @description Computes the logarithms for a specified numeric vector. +#' This function is similar to the R \code{log} function. by default natural logarithms. #' @details Server function called: \code{logDS} #' @param x a character string providing the name of a numerical vector. #' @param base a positive number, the base for which logarithms are computed. #' Default \code{exp(1)}. #' @param newobj a character string that provides the name for the output variable #' that is stored on the server-side. Default \code{log.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. #' If the \code{datasources} argument is not specified #' the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}. -#' @return \code{ds.log} returns a vector for each study of the transformed values for the numeric vector -#' specified in the argument \code{x}. The created vectors are stored in the server-side. +#' @return \code{ds.log} returns a vector for each study of the transformed values for the numeric vector +#' specified in the argument \code{x}. The created vectors are stored in the server-side. #' @author DataSHIELD Development Team #' @export #' @examples #' \dontrun{ -#' -#' ## Version 6, for version 5 see the Wiki +#' +#' ## Version 6, for version 5 see the Wiki #' # Connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') -#' +#' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") -#' +#' #' logindata <- builder$build() -#' +#' #' # Log onto the remote Opal training servers -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Calculating the log value of the 'PM_BMI_CONTINUOUS' variable -#' +#' #' ds.log(x = "D$PM_BMI_CONTINUOUS", #' base = exp(2), #' newobj = "log.PM_BMI_CONTINUOUS", #' datasources = connections[1]) #only the first Opal server is used (study1) #' #' # clear the Datashield R sessions and logout -#' datashield.logout(connections) +#' datashield.logout(connections) #'} #' ds.log <- function(x=NULL, base=exp(1), newobj=NULL, datasources=NULL){ diff --git a/R/ds.sqrt.R b/R/ds.sqrt.R index 3075f36d7..0f37fb6ea 100644 --- a/R/ds.sqrt.R +++ b/R/ds.sqrt.R @@ -1,16 +1,16 @@ #' #' @title Computes the square root values of a variable -#' @description Computes the square root values for a specified numeric or integer vector. +#' @description Computes the square root values for a specified numeric or integer vector. #' This function is similar to R function \code{sqrt}. -#' @details The function calls the server-side function \code{sqrtDS} that computes the -#' square root values of the elements of a numeric or integer vector and assigns a new vector -#' with those square root values on the server-side. The name of the new generated vector is +#' @details The function calls the server-side function \code{sqrtDS} that computes the +#' square root values of the elements of a numeric or integer vector and assigns a new vector +#' with those square root values on the server-side. The name of the new generated vector is #' specified by the user through the argument \code{newobj}, otherwise is named by default to #' \code{sqrt.newobj}. #' @param x a character string providing the name of a numeric or an integer vector. #' @param newobj a character string that provides the name for the output variable -#' that is stored on the data servers. Default name is set to \code{sqrt.newobj}. -#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +#' that is stored on the data servers. Default name is set to \code{sqrt.newobj}. +#' @param datasources a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. #' If the \code{datasources} argument is not specified the default set of connections will be #' used: see \code{\link[DSI]{datashield.connections_default}}. #' @return \code{ds.sqrt} assigns a vector for each study that includes the square root values of @@ -22,34 +22,34 @@ #' \dontrun{ #' #' # Connecting to the Opal servers -#' +#' #' require('DSI') #' require('DSOpal') #' require('dsBaseClient') -#' +#' #' builder <- DSI::newDSLoginBuilder() -#' builder$append(server = "study1", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study1", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM1", driver = "OpalDriver") -#' builder$append(server = "study2", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' builder$append(server = "study2", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM2", driver = "OpalDriver") #' builder$append(server = "study3", -#' url = "http://192.168.56.100:8080/", -#' user = "administrator", password = "datashield_test&", +#' url = "http://192.168.56.100:8080/", +#' user = "administrator", password = "datashield_test&", #' table = "CNSIM.CNSIM3", driver = "OpalDriver") -#' +#' #' logindata <- builder$build() -#' +#' #' # Log onto the remote Opal training servers -#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") -#' +#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") +#' #' # Example 1: Get the square root of LAB_HDL variable #' ds.sqrt(x='D$LAB_HDL', newobj='LAB_HDL.sqrt', datasources=connections) #' # compare the mean of LAB_HDL and of LAB_HDL.sqrt -#' # Note here that the number of missing values is bigger in the LAB_HDL.sqrt +#' # Note here that the number of missing values is bigger in the LAB_HDL.sqrt # # vector, because the variable LAB_HDL includes negative values which # # don't have real square roots and those values are returned as NAs. #' ds.mean(x='D$LAB_HDL', datasources=connections) @@ -64,7 +64,7 @@ #' ds.table(rvar='sqrt.vector')$output.list$TABLE_rvar.by.study_counts #' #' # clear the Datashield R sessions and logout -#' datashield.logout(connections) +#' datashield.logout(connections) #' #' } #' diff --git a/man/ds.abs.Rd b/man/ds.abs.Rd index 9f04d01e2..639ebd3e9 100644 --- a/man/ds.abs.Rd +++ b/man/ds.abs.Rd @@ -12,7 +12,7 @@ ds.abs(x = NULL, newobj = NULL, datasources = NULL) \item{newobj}{a character string that provides the name for the output variable that is stored on the data servers. Default name is set to \code{abs.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } @@ -22,13 +22,13 @@ the input numeric or integer vector specified in the argument \code{x}. The crea are stored in the servers. } \description{ -Computes the absolute values for a specified numeric or integer vector. +Computes the absolute values for a specified numeric or integer vector. This function is similar to R function \code{abs}. } \details{ -The function calls the server-side function \code{absDS} that computes the -absolute values of the elements of a numeric or integer vector and assigns a new vector -with those absolute values on the server-side. The name of the new generated vector is +The function calls the server-side function \code{absDS} that computes the +absolute values of the elements of a numeric or integer vector and assigns a new vector +with those absolute values on the server-side. The name of the new generated vector is specified by the user through the argument \code{newobj}, otherwise is named by default to \code{abs.newobj}. } @@ -42,24 +42,24 @@ specified by the user through the argument \code{newobj}, otherwise is named by require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") - + logindata <- builder$build() - + # Log onto the remote Opal training servers - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Example 1: Generate a normally distributed variable with zero mean and variance equal # to one and then get their absolute values ds.rNorm(samp.size=100, mean=0, sd=1, newobj='var.norm', datasources=connections) @@ -67,11 +67,11 @@ specified by the user through the argument \code{newobj}, otherwise is named by ds.summary(x='var.norm', datasources=connections) ds.abs(x='var.norm', newobj='var.norm.abs', datasources=connections) # check now the changes in the quantiles - ds.summary(x='var.norm.abs', datasources=connections) + ds.summary(x='var.norm.abs', datasources=connections) # Example 2: Generate a sequence of negative integer numbers from -200 to -100 # and then get their absolute values - ds.seq(FROM.value.char = '-200', TO.value.char = '-100', BY.value.char = '1', + ds.seq(FROM.value.char = '-200', TO.value.char = '-100', BY.value.char = '1', newobj='negative.integers', datasources=connections) # check the quantiles ds.summary(x='negative.integers', datasources=connections) @@ -80,7 +80,7 @@ specified by the user through the argument \code{newobj}, otherwise is named by ds.summary(x='positive.integers', datasources=connections) # clear the Datashield R sessions and logout - datashield.logout(connections) + datashield.logout(connections) } diff --git a/man/ds.asCharacter.Rd b/man/ds.asCharacter.Rd index 450b03e7e..29ceabe07 100644 --- a/man/ds.asCharacter.Rd +++ b/man/ds.asCharacter.Rd @@ -13,16 +13,16 @@ character.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{ascharacter.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ -\code{ds.asCharacter} returns the object converted into a class character +\code{ds.asCharacter} returns the object converted into a class character that is written to the server-side. } \description{ -Converts the input object into a character class. +Converts the input object into a character class. This function is based on the native R function \code{as.character}. } \details{ @@ -31,7 +31,7 @@ Server function called: \code{asCharacterDS} \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -39,31 +39,31 @@ Server function called: \code{asCharacterDS} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into a class character ds.asCharacter(x.name = "D$LAB_TSC", newobj = "char.obj", datasources = connections[1]) #only the first Opal server is used ("study1") - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.asDataMatrix.Rd b/man/ds.asDataMatrix.Rd index 81198870e..7cc1206cf 100644 --- a/man/ds.asDataMatrix.Rd +++ b/man/ds.asDataMatrix.Rd @@ -7,18 +7,18 @@ ds.asDataMatrix(x.name = NULL, newobj = NULL, datasources = NULL) } \arguments{ -\item{x.name}{a character string providing the name of the input object to be coerced to +\item{x.name}{a character string providing the name of the input object to be coerced to a matrix.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{asdatamatrix.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ -\code{ds.asDataMatrix} returns the object converted into a matrix +\code{ds.asDataMatrix} returns the object converted into a matrix that is written to the server-side. } \description{ @@ -26,14 +26,14 @@ Coerces an R object into a matrix maintaining original class for all columns in data frames. } \details{ -This function is based on the native R function \code{data.matrix}. +This function is based on the native R function \code{data.matrix}. Server function called: \code{asDataMatrixDS}. } \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -41,31 +41,31 @@ Server function called: \code{asDataMatrixDS}. require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into a matrix ds.asDataMatrix(x.name = "D", newobj = "mat.obj", datasources = connections[1]) #only the first Opal server is used ("study1") - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.asInteger.Rd b/man/ds.asInteger.Rd index 72aaea6ba..d8c696dbe 100644 --- a/man/ds.asInteger.Rd +++ b/man/ds.asInteger.Rd @@ -7,13 +7,13 @@ ds.asInteger(x.name = NULL, newobj = NULL, datasources = NULL) } \arguments{ -\item{x.name}{a character string providing the name of the input object to be coerced to +\item{x.name}{a character string providing the name of the input object to be coerced to an integer.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{asinteger.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } @@ -26,12 +26,12 @@ Coerces an R object into an integer class. This function is based on the native R function \code{as.integer}. } \details{ -This function is based on the native R function \code{as.integer}. - The only difference is that the DataSHIELD -function first converts the values of the input object into characters and then convert -those to integers. This addition, +This function is based on the native R function \code{as.integer}. + The only difference is that the DataSHIELD +function first converts the values of the input object into characters and then convert +those to integers. This addition, it is important for the case where the input object is of class -factor having integers as levels. +factor having integers as levels. In that case, the native R \code{as.integer} function returns the underlying level codes and not the values as integers. For example \code{as.integer} in R @@ -46,7 +46,7 @@ Server function called: \code{asIntegerDS} \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -54,32 +54,32 @@ Server function called: \code{asIntegerDS} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into an integer ds.asInteger(x.name = "D$LAB_TSC", newobj = "int.obj", datasources = connections[1]) #only the first Opal server is used ("study1") - ds.class(x = "int.obj", datasources = connections[1]) - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + ds.class(x = "int.obj", datasources = connections[1]) + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.asList.Rd b/man/ds.asList.Rd index bbfb6c9db..1b96bb027 100644 --- a/man/ds.asList.Rd +++ b/man/ds.asList.Rd @@ -7,18 +7,18 @@ ds.asList(x.name = NULL, newobj = NULL, datasources = NULL) } \arguments{ -\item{x.name}{a character string providing the name of the input object to be coerced to +\item{x.name}{a character string providing the name of the input object to be coerced to a list.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{aslist.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ -\code{ds.asList} returns the R object converted into a list +\code{ds.asList} returns the R object converted into a list which is written to the server-side. } \description{ @@ -31,7 +31,7 @@ Server function called: \code{asListDS} \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -39,32 +39,32 @@ Server function called: \code{asListDS} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into a List ds.asList(x.name = "D", - newobj = "D.asList", + newobj = "D.asList", datasources = connections[1]) #only the first Opal server is used ("study1") - ds.class(x = "D.asList", datasources = connections[1]) - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + ds.class(x = "D.asList", datasources = connections[1]) + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.asLogical.Rd b/man/ds.asLogical.Rd index 9fa8f3d45..8b277f517 100644 --- a/man/ds.asLogical.Rd +++ b/man/ds.asLogical.Rd @@ -7,13 +7,13 @@ ds.asLogical(x.name = NULL, newobj = NULL, datasources = NULL) } \arguments{ -\item{x.name}{a character string providing the name of the +\item{x.name}{a character string providing the name of the input object to be coerced to a logical.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{aslogical.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } @@ -31,7 +31,7 @@ Server function called: \code{asLogicalDS} \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -39,32 +39,32 @@ Server function called: \code{asLogicalDS} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into a logical - ds.asLogical(x.name = "D$LAB_TSC", - newobj = "logical.obj", + ds.asLogical(x.name = "D$LAB_TSC", + newobj = "logical.obj", datasources =connections[1]) #only the first Opal server is used ("study1") - ds.class(x = "logical.obj", datasources = connections[1]) - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + ds.class(x = "logical.obj", datasources = connections[1]) + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.asMatrix.Rd b/man/ds.asMatrix.Rd index e16533223..e68d97038 100644 --- a/man/ds.asMatrix.Rd +++ b/man/ds.asMatrix.Rd @@ -7,36 +7,36 @@ ds.asMatrix(x.name = NULL, newobj = NULL, datasources = NULL) } \arguments{ -\item{x.name}{a character string providing the name of the input object to be coerced to +\item{x.name}{a character string providing the name of the input object to be coerced to a matrix.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{asmatrix.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ -\code{ds.asMatrix} returns the object converted into a matrix +\code{ds.asMatrix} returns the object converted into a matrix that is written to the server-side. } \description{ -Coerces an R object into a matrix. +Coerces an R object into a matrix. This converts all columns into character class. } \details{ -This function is based on the native R function \code{as.matrix}. +This function is based on the native R function \code{as.matrix}. If this function is applied to a data frame, all columns are converted into a character class. If you wish to convert a data frame to a matrix but maintain all data columns in their -original class you should use the function \code{ds.asDataMatrix}. +original class you should use the function \code{ds.asDataMatrix}. Server function called: \code{asMatrixDS} } \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -44,31 +44,31 @@ Server function called: \code{asMatrixDS} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into a matrix ds.asMatrix(x.name = "D", newobj = "mat.obj", datasources = connections[1]) #only the first Opal server is used ("study1") - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.asNumeric.Rd b/man/ds.asNumeric.Rd index 3f7875d93..6e948d367 100644 --- a/man/ds.asNumeric.Rd +++ b/man/ds.asNumeric.Rd @@ -7,13 +7,13 @@ ds.asNumeric(x.name = NULL, newobj = NULL, datasources = NULL) } \arguments{ -\item{x.name}{a character string providing the name of the input object to be coerced to +\item{x.name}{a character string providing the name of the input object to be coerced to a numeric.} \item{newobj}{a character string that provides the name for the output object that is stored on the data servers. Default \code{asnumeric.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } @@ -22,22 +22,22 @@ the default set of connections will be used: see \code{\link[DSI]{datashield.con that is written to the server-side. } \description{ -Coerces an R object into a numeric class. +Coerces an R object into a numeric class. This function is based on the native R function \code{as.numeric}. } \details{ This function is based on the native R function \code{as.numeric}. -However, it behaves differently with some specific classes of variables. For example, if the input +However, it behaves differently with some specific classes of variables. For example, if the input object is of class factor, it first converts its values into characters and then convert those to numerics. This behaviour is important for the case where the input object is of class factor having -numbers as levels. In that case, the native R -\code{as.numeric} function returns the underlying level codes and not the values as numbers. +numbers as levels. In that case, the native R +\code{as.numeric} function returns the underlying level codes and not the values as numbers. For example \code{as.numeric} in R converts the factor vector: \cr 0 1 1 2 1 0 1 0 2 2 2 1 \cr Levels: 0 1 2 \cr to the following numeric vector: 1 2 2 3 2 1 2 1 3 3 3 2 \cr -In contrast DataSHIELD converts an input factor with numeric +In contrast DataSHIELD converts an input factor with numeric levels to its original numeric values. Server function called: \code{asNumericDS} @@ -45,7 +45,7 @@ Server function called: \code{asNumericDS} \examples{ \dontrun{ ## Version 6, for version 5 see the Wiki - + # connecting to the Opal servers require('DSI') @@ -53,32 +53,32 @@ Server function called: \code{asNumericDS} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") logindata <- builder$build() - - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Converting the R object into a numeric class ds.asNumeric(x.name = "D$LAB_TSC", newobj = "num.obj", datasources = connections[1]) #only the first Opal server is used ("study1") - ds.class(x = "num.obj", datasources = connections[1]) - - # Clear the Datashield R sessions and logout - datashield.logout(connections) - -} + ds.class(x = "num.obj", datasources = connections[1]) + + # Clear the Datashield R sessions and logout + datashield.logout(connections) + +} } \author{ DataSHIELD Development Team diff --git a/man/ds.exp.Rd b/man/ds.exp.Rd index 4e45692cf..97ba15679 100644 --- a/man/ds.exp.Rd +++ b/man/ds.exp.Rd @@ -12,16 +12,16 @@ ds.exp(x = NULL, newobj = NULL, datasources = NULL) \item{newobj}{a character string that provides the name for the output variable that is stored on the data servers. Default \code{exp.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. -If the \code{datasources} argument is not specified +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ -\code{ds.exp} returns a vector for each study of the exponential values for the numeric vector +\code{ds.exp} returns a vector for each study of the exponential values for the numeric vector specified in the argument \code{x}. The created vectors are stored in the server-side. } \description{ -Computes the exponential values for a specified numeric vector. +Computes the exponential values for a specified numeric vector. This function is similar to R function \code{exp}. } \details{ @@ -30,7 +30,7 @@ Server function called: \code{expDS}. \examples{ \dontrun{ - ## Version 6, for version 5 see the Wiki + ## Version 6, for version 5 see the Wiki # Connecting to the Opal servers require('DSI') @@ -38,31 +38,31 @@ Server function called: \code{expDS}. require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") - + logindata <- builder$build() - + # Log onto the remote Opal training servers - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # compute exponential function of the 'PM_BMI_CONTINUOUS' variable ds.exp(x = "D$PM_BMI_CONTINUOUS", newobj = "exp.PM_BMI_CONTINUOUS", datasources = connections[1]) #only the first Opal server is used (study1) # clear the Datashield R sessions and logout - datashield.logout(connections) + datashield.logout(connections) } diff --git a/man/ds.log.Rd b/man/ds.log.Rd index bbe9cadfa..661954cdb 100644 --- a/man/ds.log.Rd +++ b/man/ds.log.Rd @@ -15,16 +15,16 @@ Default \code{exp(1)}.} \item{newobj}{a character string that provides the name for the output variable that is stored on the server-side. Default \code{log.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } \value{ -\code{ds.log} returns a vector for each study of the transformed values for the numeric vector +\code{ds.log} returns a vector for each study of the transformed values for the numeric vector specified in the argument \code{x}. The created vectors are stored in the server-side. } \description{ -Computes the logarithms for a specified numeric vector. +Computes the logarithms for a specified numeric vector. This function is similar to the R \code{log} function. by default natural logarithms. } \details{ @@ -33,7 +33,7 @@ Server function called: \code{logDS} \examples{ \dontrun{ - ## Version 6, for version 5 see the Wiki + ## Version 6, for version 5 see the Wiki # Connecting to the Opal servers require('DSI') @@ -41,33 +41,33 @@ Server function called: \code{logDS} require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") - + logindata <- builder$build() - + # Log onto the remote Opal training servers - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Calculating the log value of the 'PM_BMI_CONTINUOUS' variable - + ds.log(x = "D$PM_BMI_CONTINUOUS", base = exp(2), newobj = "log.PM_BMI_CONTINUOUS", datasources = connections[1]) #only the first Opal server is used (study1) # clear the Datashield R sessions and logout - datashield.logout(connections) + datashield.logout(connections) } } diff --git a/man/ds.sqrt.Rd b/man/ds.sqrt.Rd index 90120ab27..638d26a5f 100644 --- a/man/ds.sqrt.Rd +++ b/man/ds.sqrt.Rd @@ -12,7 +12,7 @@ ds.sqrt(x = NULL, newobj = NULL, datasources = NULL) \item{newobj}{a character string that provides the name for the output variable that is stored on the data servers. Default name is set to \code{sqrt.newobj}.} -\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. +\item{datasources}{a list of \code{\link[DSI]{DSConnection-class}} objects obtained after login. If the \code{datasources} argument is not specified the default set of connections will be used: see \code{\link[DSI]{datashield.connections_default}}.} } @@ -22,13 +22,13 @@ the input numeric or integer vector specified in the argument \code{x}. The crea are stored in the servers. } \description{ -Computes the square root values for a specified numeric or integer vector. +Computes the square root values for a specified numeric or integer vector. This function is similar to R function \code{sqrt}. } \details{ -The function calls the server-side function \code{sqrtDS} that computes the -square root values of the elements of a numeric or integer vector and assigns a new vector -with those square root values on the server-side. The name of the new generated vector is +The function calls the server-side function \code{sqrtDS} that computes the +square root values of the elements of a numeric or integer vector and assigns a new vector +with those square root values on the server-side. The name of the new generated vector is specified by the user through the argument \code{newobj}, otherwise is named by default to \code{sqrt.newobj}. } @@ -42,28 +42,28 @@ specified by the user through the argument \code{newobj}, otherwise is named by require('dsBaseClient') builder <- DSI::newDSLoginBuilder() - builder$append(server = "study1", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study1", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM1", driver = "OpalDriver") - builder$append(server = "study2", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + builder$append(server = "study2", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM2", driver = "OpalDriver") builder$append(server = "study3", - url = "http://192.168.56.100:8080/", - user = "administrator", password = "datashield_test&", + url = "http://192.168.56.100:8080/", + user = "administrator", password = "datashield_test&", table = "CNSIM.CNSIM3", driver = "OpalDriver") - + logindata <- builder$build() - + # Log onto the remote Opal training servers - connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") - + connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") + # Example 1: Get the square root of LAB_HDL variable ds.sqrt(x='D$LAB_HDL', newobj='LAB_HDL.sqrt', datasources=connections) # compare the mean of LAB_HDL and of LAB_HDL.sqrt - # Note here that the number of missing values is bigger in the LAB_HDL.sqrt + # Note here that the number of missing values is bigger in the LAB_HDL.sqrt ds.mean(x='D$LAB_HDL', datasources=connections) ds.mean(x='LAB_HDL.sqrt', datasources=connections) @@ -75,7 +75,7 @@ specified by the user through the argument \code{newobj}, otherwise is named by ds.table(rvar='sqrt.vector')$output.list$TABLE_rvar.by.study_counts # clear the Datashield R sessions and logout - datashield.logout(connections) + datashield.logout(connections) } From 97575451381765f448522d7ec627c17277184178 Mon Sep 17 00:00:00 2001 From: Tim Cadman <41470917+timcadman@users.noreply.github.com> Date: Mon, 16 Mar 2026 10:09:01 +0100 Subject: [PATCH 4/7] added missing arg tests --- tests/testthat/test-arg-ds.abs.R | 31 +++++++++++++++++++++++++++++++ tests/testthat/test-arg-ds.sqrt.R | 31 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 tests/testthat/test-arg-ds.abs.R create mode 100644 tests/testthat/test-arg-ds.sqrt.R diff --git a/tests/testthat/test-arg-ds.abs.R b/tests/testthat/test-arg-ds.abs.R new file mode 100644 index 000000000..fc1e26c33 --- /dev/null +++ b/tests/testthat/test-arg-ds.abs.R @@ -0,0 +1,31 @@ +#------------------------------------------------------------------------------- +# Copyright (c) 2018-2022 University of Newcastle upon Tyne. All rights reserved. +# Copyright (c) 2022-2025 Arjuna Technologies, Newcastle upon Tyne. All rights reserved. +# +# This program and the accompanying materials +# are made available under the terms of the GNU Public License v3.0. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +#------------------------------------------------------------------------------- + +# +# Set up +# + +connect.studies.dataset.cnsim(list("LAB_TSC")) + +# +# Tests +# + +# context("ds.abs::arg::test errors") +test_that("abs_errors", { + expect_error(ds.abs(), "Please provide the name of the input object!", fixed=TRUE) +}) + +# +# Done +# + +disconnect.studies.dataset.cnsim() diff --git a/tests/testthat/test-arg-ds.sqrt.R b/tests/testthat/test-arg-ds.sqrt.R new file mode 100644 index 000000000..fc5baf37f --- /dev/null +++ b/tests/testthat/test-arg-ds.sqrt.R @@ -0,0 +1,31 @@ +#------------------------------------------------------------------------------- +# Copyright (c) 2018-2022 University of Newcastle upon Tyne. All rights reserved. +# Copyright (c) 2022-2025 Arjuna Technologies, Newcastle upon Tyne. All rights reserved. +# +# This program and the accompanying materials +# are made available under the terms of the GNU Public License v3.0. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +#------------------------------------------------------------------------------- + +# +# Set up +# + +connect.studies.dataset.cnsim(list("LAB_TSC")) + +# +# Tests +# + +# context("ds.sqrt::arg::test errors") +test_that("sqrt_errors", { + expect_error(ds.sqrt(), "Please provide the name of the input object!", fixed=TRUE) +}) + +# +# Done +# + +disconnect.studies.dataset.cnsim() From f8d0ab472844f23e2a125f6fffda4b328bace0fc Mon Sep 17 00:00:00 2001 From: Tim Cadman <41470917+timcadman@users.noreply.github.com> Date: Mon, 16 Mar 2026 10:53:37 +0100 Subject: [PATCH 5/7] test: check object creation --- tests/testthat/test-smk-ds.asList.R | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/testthat/test-smk-ds.asList.R b/tests/testthat/test-smk-ds.asList.R index 9fbcfd425..34c3a3233 100644 --- a/tests/testthat/test-smk-ds.asList.R +++ b/tests/testthat/test-smk-ds.asList.R @@ -27,18 +27,12 @@ test_that("setup", { # context("ds.asList::smk::simple test") test_that("simple test", { - res <- ds.asList(x.name="D$GENDER") - - expect_length(res, 3) - expect_length(res$sim1, 2) - expect_equal(res$sim1$return.message, "New object created") - expect_equal(res$sim1$class.of.newobj, "Class of is 'list'") - expect_length(res$sim2, 2) - expect_equal(res$sim2$return.message, "New object created") - expect_equal(res$sim2$class.of.newobj, "Class of is 'list'") - expect_length(res$sim3, 2) - expect_equal(res$sim3$return.message, "New object created") - expect_equal(res$sim3$class.of.newobj, "Class of is 'list'") + ds.asList(x.name="D$GENDER") + + res.class <- ds.class("aslist.newobj") + expect_equal(res.class$sim1, "list") + expect_equal(res.class$sim2, "list") + expect_equal(res.class$sim3, "list") }) # From 65b08443ee58fdb986d4a68cbdc02b6552bba753 Mon Sep 17 00:00:00 2001 From: Tim Cadman <41470917+timcadman@users.noreply.github.com> Date: Mon, 16 Mar 2026 10:53:55 +0100 Subject: [PATCH 6/7] test: add performance tests --- tests/testthat/test-perf-ds.asCharacter.R | 58 ++++++++++++++++++++++ tests/testthat/test-perf-ds.asDataMatrix.R | 58 ++++++++++++++++++++++ tests/testthat/test-perf-ds.asLogical.R | 58 ++++++++++++++++++++++ tests/testthat/test-perf-ds.asMatrix.R | 58 ++++++++++++++++++++++ tests/testthat/test-perf-ds.exp.R | 58 ++++++++++++++++++++++ tests/testthat/test-perf-ds.log.R | 58 ++++++++++++++++++++++ tests/testthat/test-perf-ds.sqrt.R | 58 ++++++++++++++++++++++ 7 files changed, 406 insertions(+) create mode 100644 tests/testthat/test-perf-ds.asCharacter.R create mode 100644 tests/testthat/test-perf-ds.asDataMatrix.R create mode 100644 tests/testthat/test-perf-ds.asLogical.R create mode 100644 tests/testthat/test-perf-ds.asMatrix.R create mode 100644 tests/testthat/test-perf-ds.exp.R create mode 100644 tests/testthat/test-perf-ds.log.R create mode 100644 tests/testthat/test-perf-ds.sqrt.R diff --git a/tests/testthat/test-perf-ds.asCharacter.R b/tests/testthat/test-perf-ds.asCharacter.R new file mode 100644 index 000000000..f9c08b7df --- /dev/null +++ b/tests/testthat/test-perf-ds.asCharacter.R @@ -0,0 +1,58 @@ +#------------------------------------------------------------------------------- +# +# This program and the accompanying materials +# are made available under the terms of the GNU Public License v3.0. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +#------------------------------------------------------------------------------- + +# +# Set up +# + +# context("ds.asCharacter::perf::setup") +connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG")) + +# +# Tests +# + +# context("ds.asCharacter::perf:0") +test_that("combine - performance", { + .durationSec <- 30 # seconds + .count <- 0 + .start.time <- Sys.time() + .current.time <- .start.time + + while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) { + ds.asCharacter("D$LAB_TSC", newobj = "perf.newobj") + + .count <- .count + 1 + .current.time <- Sys.time() + } + + .current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]]) + .reference.rate <- perf.reference.rate("ds.asCharacter::perf::0") + if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) { + print(paste("ds.asCharacter::perf::0 ", .current.rate, 0.5, 2.0)) + perf.reference.save("ds.asCharacter::perf::0", .current.rate, 0.5, 2.0) + } else { + print(paste("ds.asCharacter::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = '')) + } + + .reference.rate <- perf.reference.rate("ds.asCharacter::perf::0") + .reference.tolerance.lower <- perf.reference.tolerance.lower("ds.asCharacter::perf::0") + .reference.tolerance.upper <- perf.reference.tolerance.upper("ds.asCharacter::perf::0") + + expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate") + expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate") +}) + +# +# Done +# + +# context("ds.asCharacter::perf::shutdown") +disconnect.studies.dataset.cnsim() +# context("ds.asCharacter::perf::done") diff --git a/tests/testthat/test-perf-ds.asDataMatrix.R b/tests/testthat/test-perf-ds.asDataMatrix.R new file mode 100644 index 000000000..329c1e2f6 --- /dev/null +++ b/tests/testthat/test-perf-ds.asDataMatrix.R @@ -0,0 +1,58 @@ +#------------------------------------------------------------------------------- +# +# This program and the accompanying materials +# are made available under the terms of the GNU Public License v3.0. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +#------------------------------------------------------------------------------- + +# +# Set up +# + +# context("ds.asDataMatrix::perf::setup") +connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG")) + +# +# Tests +# + +# context("ds.asDataMatrix::perf:0") +test_that("combine - performance", { + .durationSec <- 30 # seconds + .count <- 0 + .start.time <- Sys.time() + .current.time <- .start.time + + while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) { + ds.asDataMatrix(x.name = "D", newobj = "perf.newobj") + + .count <- .count + 1 + .current.time <- Sys.time() + } + + .current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]]) + .reference.rate <- perf.reference.rate("ds.asDataMatrix::perf::0") + if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) { + print(paste("ds.asDataMatrix::perf::0 ", .current.rate, 0.5, 2.0)) + perf.reference.save("ds.asDataMatrix::perf::0", .current.rate, 0.5, 2.0) + } else { + print(paste("ds.asDataMatrix::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = '')) + } + + .reference.rate <- perf.reference.rate("ds.asDataMatrix::perf::0") + .reference.tolerance.lower <- perf.reference.tolerance.lower("ds.asDataMatrix::perf::0") + .reference.tolerance.upper <- perf.reference.tolerance.upper("ds.asDataMatrix::perf::0") + + expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate") + expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate") +}) + +# +# Done +# + +# context("ds.asDataMatrix::perf::shutdown") +disconnect.studies.dataset.cnsim() +# context("ds.asDataMatrix::perf::done") diff --git a/tests/testthat/test-perf-ds.asLogical.R b/tests/testthat/test-perf-ds.asLogical.R new file mode 100644 index 000000000..f3c4d43d9 --- /dev/null +++ b/tests/testthat/test-perf-ds.asLogical.R @@ -0,0 +1,58 @@ +#------------------------------------------------------------------------------- +# +# This program and the accompanying materials +# are made available under the terms of the GNU Public License v3.0. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +#------------------------------------------------------------------------------- + +# +# Set up +# + +# context("ds.asLogical::perf::setup") +connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG")) + +# +# Tests +# + +# context("ds.asLogical::perf:0") +test_that("combine - performance", { + .durationSec <- 30 # seconds + .count <- 0 + .start.time <- Sys.time() + .current.time <- .start.time + + while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) { + ds.asLogical("D$LAB_TSC", newobj = "perf.newobj") + + .count <- .count + 1 + .current.time <- Sys.time() + } + + .current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]]) + .reference.rate <- perf.reference.rate("ds.asLogical::perf::0") + if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) { + print(paste("ds.asLogical::perf::0 ", .current.rate, 0.5, 2.0)) + perf.reference.save("ds.asLogical::perf::0", .current.rate, 0.5, 2.0) + } else { + print(paste("ds.asLogical::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = '')) + } + + .reference.rate <- perf.reference.rate("ds.asLogical::perf::0") + .reference.tolerance.lower <- perf.reference.tolerance.lower("ds.asLogical::perf::0") + .reference.tolerance.upper <- perf.reference.tolerance.upper("ds.asLogical::perf::0") + + expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate") + expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate") +}) + +# +# Done +# + +# context("ds.asLogical::perf::shutdown") +disconnect.studies.dataset.cnsim() +# context("ds.asLogical::perf::done") \ No newline at end of file diff --git a/tests/testthat/test-perf-ds.asMatrix.R b/tests/testthat/test-perf-ds.asMatrix.R new file mode 100644 index 000000000..a07e9605a --- /dev/null +++ b/tests/testthat/test-perf-ds.asMatrix.R @@ -0,0 +1,58 @@ +#------------------------------------------------------------------------------- +# +# This program and the accompanying materials +# are made available under the terms of the GNU Public License v3.0. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +#------------------------------------------------------------------------------- + +# +# Set up +# + +# context("ds.asMatrix::perf::setup") +connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG")) + +# +# Tests +# + +# context("ds.asMatrix::perf:0") +test_that("combine - performance", { + .durationSec <- 30 # seconds + .count <- 0 + .start.time <- Sys.time() + .current.time <- .start.time + + while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) { + ds.asMatrix(x.name = "D$LAB_TSC", newobj = "perf.newobj") + + .count <- .count + 1 + .current.time <- Sys.time() + } + + .current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]]) + .reference.rate <- perf.reference.rate("ds.asMatrix::perf::0") + if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) { + print(paste("ds.asMatrix::perf::0 ", .current.rate, 0.5, 2.0)) + perf.reference.save("ds.asMatrix::perf::0", .current.rate, 0.5, 2.0) + } else { + print(paste("ds.asMatrix::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = '')) + } + + .reference.rate <- perf.reference.rate("ds.asMatrix::perf::0") + .reference.tolerance.lower <- perf.reference.tolerance.lower("ds.asMatrix::perf::0") + .reference.tolerance.upper <- perf.reference.tolerance.upper("ds.asMatrix::perf::0") + + expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate") + expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate") +}) + +# +# Done +# + +# context("ds.asMatrix::perf::shutdown") +disconnect.studies.dataset.cnsim() +# context("ds.asMatrix::perf::done") \ No newline at end of file diff --git a/tests/testthat/test-perf-ds.exp.R b/tests/testthat/test-perf-ds.exp.R new file mode 100644 index 000000000..8ab5b3d95 --- /dev/null +++ b/tests/testthat/test-perf-ds.exp.R @@ -0,0 +1,58 @@ +#------------------------------------------------------------------------------- +# +# This program and the accompanying materials +# are made available under the terms of the GNU Public License v3.0. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +#------------------------------------------------------------------------------- + +# +# Set up +# + +# context("ds.exp::perf::setup") +connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG")) + +# +# Tests +# + +# context("ds.exp::perf:0") +test_that("combine - performance", { + .durationSec <- 30 # seconds + .count <- 0 + .start.time <- Sys.time() + .current.time <- .start.time + + while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) { + ds.exp("D$LAB_TSC", newobj = "perf.newobj") + + .count <- .count + 1 + .current.time <- Sys.time() + } + + .current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]]) + .reference.rate <- perf.reference.rate("ds.exp::perf::0") + if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) { + print(paste("ds.exp::perf::0 ", .current.rate, 0.5, 2.0)) + perf.reference.save("ds.exp::perf::0", .current.rate, 0.5, 2.0) + } else { + print(paste("ds.exp::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = '')) + } + + .reference.rate <- perf.reference.rate("ds.exp::perf::0") + .reference.tolerance.lower <- perf.reference.tolerance.lower("ds.exp::perf::0") + .reference.tolerance.upper <- perf.reference.tolerance.upper("ds.exp::perf::0") + + expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate") + expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate") +}) + +# +# Done +# + +# context("ds.exp::perf::shutdown") +disconnect.studies.dataset.cnsim() +# context("ds.exp::perf::done") diff --git a/tests/testthat/test-perf-ds.log.R b/tests/testthat/test-perf-ds.log.R new file mode 100644 index 000000000..96ab0be27 --- /dev/null +++ b/tests/testthat/test-perf-ds.log.R @@ -0,0 +1,58 @@ +#------------------------------------------------------------------------------- +# +# This program and the accompanying materials +# are made available under the terms of the GNU Public License v3.0. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +#------------------------------------------------------------------------------- + +# +# Set up +# + +# context("ds.log::perf::setup") +connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG")) + +# +# Tests +# + +# context("ds.log::perf:0") +test_that("combine - performance", { + .durationSec <- 30 # seconds + .count <- 0 + .start.time <- Sys.time() + .current.time <- .start.time + + while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) { + ds.log("D$LAB_TSC", newobj = "perf.newobj") + + .count <- .count + 1 + .current.time <- Sys.time() + } + + .current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]]) + .reference.rate <- perf.reference.rate("ds.log::perf::0") + if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) { + print(paste("ds.log::perf::0 ", .current.rate, 0.5, 2.0)) + perf.reference.save("ds.log::perf::0", .current.rate, 0.5, 2.0) + } else { + print(paste("ds.log::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = '')) + } + + .reference.rate <- perf.reference.rate("ds.log::perf::0") + .reference.tolerance.lower <- perf.reference.tolerance.lower("ds.log::perf::0") + .reference.tolerance.upper <- perf.reference.tolerance.upper("ds.log::perf::0") + + expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate") + expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate") +}) + +# +# Done +# + +# context("ds.log::perf::shutdown") +disconnect.studies.dataset.cnsim() +# context("ds.log::perf::done") diff --git a/tests/testthat/test-perf-ds.sqrt.R b/tests/testthat/test-perf-ds.sqrt.R new file mode 100644 index 000000000..dffdbbb64 --- /dev/null +++ b/tests/testthat/test-perf-ds.sqrt.R @@ -0,0 +1,58 @@ +#------------------------------------------------------------------------------- +# +# This program and the accompanying materials +# are made available under the terms of the GNU Public License v3.0. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +#------------------------------------------------------------------------------- + +# +# Set up +# + +# context("ds.sqrt::perf::setup") +connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG")) + +# +# Tests +# + +# context("ds.sqrt::perf:0") +test_that("combine - performance", { + .durationSec <- 30 # seconds + .count <- 0 + .start.time <- Sys.time() + .current.time <- .start.time + + while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) { + ds.sqrt("D$LAB_TSC", newobj = "perf.newobj") + + .count <- .count + 1 + .current.time <- Sys.time() + } + + .current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]]) + .reference.rate <- perf.reference.rate("ds.sqrt::perf::0") + if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) { + print(paste("ds.sqrt::perf::0 ", .current.rate, 0.5, 2.0)) + perf.reference.save("ds.sqrt::perf::0", .current.rate, 0.5, 2.0) + } else { + print(paste("ds.sqrt::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = '')) + } + + .reference.rate <- perf.reference.rate("ds.sqrt::perf::0") + .reference.tolerance.lower <- perf.reference.tolerance.lower("ds.sqrt::perf::0") + .reference.tolerance.upper <- perf.reference.tolerance.upper("ds.sqrt::perf::0") + + expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate") + expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate") +}) + +# +# Done +# + +# context("ds.sqrt::perf::shutdown") +disconnect.studies.dataset.cnsim() +# context("ds.sqrt::perf::done") From f2ea79dfbe5d9b48deb972956e96f68d3605804d Mon Sep 17 00:00:00 2001 From: Tim Cadman <41470917+timcadman@users.noreply.github.com> Date: Mon, 16 Mar 2026 12:44:54 +0100 Subject: [PATCH 7/7] removed redundant existence checks, explicitly check silent return --- tests/testthat/test-smk-ds.abs.R | 4 +-- tests/testthat/test-smk-ds.asCharacter.R | 2 +- tests/testthat/test-smk-ds.asDataMatrix.R | 2 +- tests/testthat/test-smk-ds.asInteger.R | 2 +- tests/testthat/test-smk-ds.asList.R | 2 +- tests/testthat/test-smk-ds.asLogical.R | 2 +- tests/testthat/test-smk-ds.asMatrix.R | 2 +- tests/testthat/test-smk-ds.asNumeric.R | 2 +- tests/testthat/test-smk-ds.exp.R | 30 +++-------------------- tests/testthat/test-smk-ds.log.R | 28 ++------------------- tests/testthat/test-smk-ds.sqrt.R | 4 +-- 11 files changed, 14 insertions(+), 66 deletions(-) diff --git a/tests/testthat/test-smk-ds.abs.R b/tests/testthat/test-smk-ds.abs.R index b64b313bf..e35c3b0dd 100644 --- a/tests/testthat/test-smk-ds.abs.R +++ b/tests/testthat/test-smk-ds.abs.R @@ -27,9 +27,7 @@ test_that("setup", { # context("ds.abs::smk") test_that("simple c", { - res <- ds.abs("D$LAB_TSC", newobj = "abs.newobj") - - expect_true(is.null(res)) + expect_silent(ds.abs("D$LAB_TSC", newobj = "abs.newobj")) res.length <- ds.length("abs.newobj") diff --git a/tests/testthat/test-smk-ds.asCharacter.R b/tests/testthat/test-smk-ds.asCharacter.R index 07d633b6c..09e13e0e2 100644 --- a/tests/testthat/test-smk-ds.asCharacter.R +++ b/tests/testthat/test-smk-ds.asCharacter.R @@ -27,7 +27,7 @@ test_that("setup", { # context("ds.asCharacter::smk::simple test") test_that("simple test", { - ds.asCharacter("D$LAB_TSC") + expect_silent(ds.asCharacter("D$LAB_TSC")) res.class <- ds.class("ascharacter.newobj") expect_equal(res.class$sim1, "character") diff --git a/tests/testthat/test-smk-ds.asDataMatrix.R b/tests/testthat/test-smk-ds.asDataMatrix.R index 4f4217251..ea6068280 100644 --- a/tests/testthat/test-smk-ds.asDataMatrix.R +++ b/tests/testthat/test-smk-ds.asDataMatrix.R @@ -27,7 +27,7 @@ test_that("setup", { # context("ds.asDataMatrix::smk::simple test") test_that("simple test", { - ds.asDataMatrix(x.name="D$GENDER") + expect_silent(ds.asDataMatrix(x.name="D$GENDER")) res.class <- ds.class("asdatamatrix.newobj") expect_length(res.class, 3) diff --git a/tests/testthat/test-smk-ds.asInteger.R b/tests/testthat/test-smk-ds.asInteger.R index 0045cb80c..ee841172f 100644 --- a/tests/testthat/test-smk-ds.asInteger.R +++ b/tests/testthat/test-smk-ds.asInteger.R @@ -27,7 +27,7 @@ test_that("setup", { # context("ds.asInteger::smk::simple test") test_that("simple test", { - ds.asInteger("D$GENDER") + expect_silent(ds.asInteger("D$GENDER")) res.class <- ds.class("asinteger.newobj") expect_equal(res.class$sim1, "integer") diff --git a/tests/testthat/test-smk-ds.asList.R b/tests/testthat/test-smk-ds.asList.R index 34c3a3233..7e1987456 100644 --- a/tests/testthat/test-smk-ds.asList.R +++ b/tests/testthat/test-smk-ds.asList.R @@ -27,7 +27,7 @@ test_that("setup", { # context("ds.asList::smk::simple test") test_that("simple test", { - ds.asList(x.name="D$GENDER") + expect_silent(ds.asList(x.name="D$GENDER")) res.class <- ds.class("aslist.newobj") expect_equal(res.class$sim1, "list") diff --git a/tests/testthat/test-smk-ds.asLogical.R b/tests/testthat/test-smk-ds.asLogical.R index 6e31ecce1..34ad87c87 100644 --- a/tests/testthat/test-smk-ds.asLogical.R +++ b/tests/testthat/test-smk-ds.asLogical.R @@ -27,7 +27,7 @@ test_that("setup", { # context("ds.asLogical::smk::simple test") test_that("simple test", { - ds.asLogical("D$LAB_TSC") + expect_silent(ds.asLogical("D$LAB_TSC")) res.class <- ds.class("aslogical.newobj") expect_equal(res.class$sim1, "logical") diff --git a/tests/testthat/test-smk-ds.asMatrix.R b/tests/testthat/test-smk-ds.asMatrix.R index b17066c2a..aa05040e2 100644 --- a/tests/testthat/test-smk-ds.asMatrix.R +++ b/tests/testthat/test-smk-ds.asMatrix.R @@ -27,7 +27,7 @@ test_that("setup", { # context("ds.asMatrix::smk::simple test") test_that("simple test", { - ds.asMatrix(x.name="D$GENDER") + expect_silent(ds.asMatrix(x.name="D$GENDER")) res.class <- ds.class("asmatrix.newobj") expect_true("matrix" %in% res.class$sim1) diff --git a/tests/testthat/test-smk-ds.asNumeric.R b/tests/testthat/test-smk-ds.asNumeric.R index aa2fdf2f1..6c5c98e20 100644 --- a/tests/testthat/test-smk-ds.asNumeric.R +++ b/tests/testthat/test-smk-ds.asNumeric.R @@ -27,7 +27,7 @@ test_that("setup", { # context("ds.asNumeric::smk::simple test") test_that("simple test", { - ds.asNumeric("D$GENDER") + expect_silent(ds.asNumeric("D$GENDER")) res.class <- ds.class("asnumeric.newobj") expect_equal(res.class$sim1, "numeric") diff --git a/tests/testthat/test-smk-ds.exp.R b/tests/testthat/test-smk-ds.exp.R index fa850fb81..6a7f7b501 100644 --- a/tests/testthat/test-smk-ds.exp.R +++ b/tests/testthat/test-smk-ds.exp.R @@ -27,19 +27,7 @@ test_that("setup", { # context("ds.exp::smk") test_that("simple exp", { - res1 <- ds.exp("D$LAB_TSC", newobj="exp1_obj") - - expect_length(res1, 0) - - res1_exists <- ds.exists("exp1_obj") - - expect_length(res1_exists, 3) - expect_length(res1_exists$sim1, 1) - expect_equal(res1_exists$sim1, TRUE) - expect_length(res1_exists$sim2, 1) - expect_equal(res1_exists$sim2, TRUE) - expect_length(res1_exists$sim3, 1) - expect_equal(res1_exists$sim3, TRUE) + expect_silent(ds.exp("D$LAB_TSC", newobj="exp1_obj")) res1_class <- ds.class("exp1_obj") @@ -53,21 +41,9 @@ test_that("simple exp", { res_as <- ds.asInteger("D$LAB_TSC", newobj="new_data") - res2 <- ds.exp("new_data", newobj="exp2_obj") - - expect_length(res2, 0) - - res2_exists <- ds.exists("exp2_obj") - - expect_length(res2_exists, 3) - expect_length(res2_exists$sim1, 1) - expect_equal(res2_exists$sim1, TRUE) - expect_length(res2_exists$sim2, 1) - expect_equal(res2_exists$sim2, TRUE) - expect_length(res2_exists$sim3, 1) - expect_equal(res2_exists$sim3, TRUE) + expect_silent(ds.exp("new_data", newobj="exp2_obj")) - res2_class <- ds.class("exp1_obj") + res2_class <- ds.class("exp2_obj") expect_length(res2_class, 3) expect_length(res2_class$sim1, 1) diff --git a/tests/testthat/test-smk-ds.log.R b/tests/testthat/test-smk-ds.log.R index c857408db..3d4699ac2 100644 --- a/tests/testthat/test-smk-ds.log.R +++ b/tests/testthat/test-smk-ds.log.R @@ -27,19 +27,7 @@ test_that("setup", { # context("ds.log::smk") test_that("simple log", { - res1 <- ds.log("D$LAB_TSC", newobj="log1_obj") - - expect_length(res1, 0) - - res1_exists <- ds.exists("log1_obj") - - expect_length(res1_exists, 3) - expect_length(res1_exists$sim1, 1) - expect_equal(res1_exists$sim1, TRUE) - expect_length(res1_exists$sim2, 1) - expect_equal(res1_exists$sim2, TRUE) - expect_length(res1_exists$sim3, 1) - expect_equal(res1_exists$sim3, TRUE) + expect_silent(ds.log("D$LAB_TSC", newobj="log1_obj")) res1_class <- ds.class("log1_obj") @@ -53,19 +41,7 @@ test_that("simple log", { res_as <- ds.asInteger("D$LAB_TSC", newobj="new_data") - res2 <- ds.log("new_data", newobj="log2_obj") - - expect_length(res2, 0) - - res2_exists <- ds.exists("log2_obj") - - expect_length(res2_exists, 3) - expect_length(res2_exists$sim1, 1) - expect_equal(res2_exists$sim1, TRUE) - expect_length(res2_exists$sim2, 1) - expect_equal(res2_exists$sim2, TRUE) - expect_length(res2_exists$sim3, 1) - expect_equal(res2_exists$sim3, TRUE) + expect_silent(ds.log("new_data", newobj="log2_obj")) res2_class <- ds.class("log2_obj") diff --git a/tests/testthat/test-smk-ds.sqrt.R b/tests/testthat/test-smk-ds.sqrt.R index ccb50c0ca..de6e3336f 100644 --- a/tests/testthat/test-smk-ds.sqrt.R +++ b/tests/testthat/test-smk-ds.sqrt.R @@ -27,9 +27,7 @@ test_that("setup", { # context("ds.sqrt::smk") test_that("simple c", { - res <- ds.sqrt("D$LAB_TSC", newobj = "sqrt.newobj") - - expect_true(is.null(res)) + expect_silent(ds.sqrt("D$LAB_TSC", newobj = "sqrt.newobj")) res.length <- ds.length("sqrt.newobj")