ds.var {dsBaseClient}R Documentation

Computes server-side vector variance


Computes the variance of a given server-side vector.


ds.var(x = NULL, type = "split", checks = FALSE, datasources = NULL)



a character specifying the name of a numerical vector.


a character string that represents the type of analysis to carry out. This can be set as 'combine', 'combined', 'combines', 'split', 'splits', 's', 'both' or 'b'. For more information see Details.


logical. If TRUE optional checks of model components will be undertaken. Default is FALSE to save time. It is suggested that checks should only be undertaken once the function call has failed.


a list of DSConnection-class objects obtained after login. If the datasources argument is not specified the default set of connections will be used: see datashield.connections_default.


This function is similar to the R function var.

The function can carry out 3 types of analysis depending on the argument type:
(1) If type is set to 'combine', 'combined', 'combines' or 'c', a global variance is calculated.
(2) If type is set to 'split', 'splits' or 's', the variance is calculated separately for each study.
(3) If type is set to 'both' or 'b', both sets of outputs are produced.

Server function called: varDS


ds.var returns to the client-side a list including:

Variance.by.Study: estimated variance, Nmissing (number of missing observations), Nvalid (number of valid observations) and Ntotal (sum of missing and valid observations) separately for each study (if type = split or type = both).
Global.Variance: estimated variance, Nmissing, Nvalid and Ntotal across all studies combined (if type = combine or type = both).
Nstudies: number of studies being analysed.
ValidityMessage: indicates if the analysis was possible.


DataSHIELD Development Team


## Not run: 

 ## Version 6, for version 5 see the Wiki
  # connecting to the Opal servers


  builder <- DSI::newDSLoginBuilder()
  builder$append(server = "study1", 
                 url = "", 
                 user = "administrator", password = "datashield_test&", 
                 table = "CNSIM.CNSIM1", driver = "OpalDriver")
  builder$append(server = "study2", 
                 url = "", 
                 user = "administrator", password = "datashield_test&", 
                 table = "CNSIM.CNSIM2", driver = "OpalDriver")
  builder$append(server = "study3",
                 url = "", 
                 user = "administrator", password = "datashield_test&", 
                 table = "CNSIM.CNSIM3", driver = "OpalDriver")
  logindata <- builder$build()
  connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D") 
  #Calculate the variance of a vector in the server-side
  ds.var(x = "D$LAB_TSC",
          type = "split",
          checks = FALSE,
          datasources = connections)
  # clear the Datashield R sessions and logout

## End(Not run)

[Package dsBaseClient version 6.3.0 ]