ds.rowColCalc: Computes rows and columns sums and means in the server-side

View source: R/ds.rowColCalc.R

ds.rowColCalcR Documentation

Computes rows and columns sums and means in the server-side

Description

Computes sums and means of rows or columns of a numeric matrix or data frame on the server-side.

Usage

ds.rowColCalc(x = NULL, operation = NULL, newobj = NULL, datasources = NULL)

Arguments

x

a character string specifying the name of a matrix or a data frame.

operation

a character string that indicates the operation to carry out: "rowSums", "colSums", "rowMeans" or "colMeans".

newobj

a character string that provides the name for the output variable that is stored on the data servers. Default rowcolcalc.newobj.

datasources

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.

Details

The function is similar to R base functions rowSums, colSums, rowMeans and colMeans with some restrictions.

The results of the calculation are not returned to the user if they are potentially revealing i.e. if the number of rows is less than the allowed number of observations.

Server functions called: classDS, dimDS and colnamesDS

Value

ds.rowColCalc returns to the server-side rows and columns sums and means.

Author(s)

DataSHIELD Development Team

Examples

## Not run: 

  ## 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&", 
                 table = "CNSIM.CNSIM1", driver = "OpalDriver")
  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&", 
                 table = "CNSIM.CNSIM3", driver = "OpalDriver")
  logindata <- builder$build()
  myvar <- list("LAB_TSC","LAB_HDL")
   
  # Log onto the remote Opal training servers
  connections <- DSI::datashield.login(logins = logindata, assign = TRUE, 
  variables = myvar, symbol = "D") 

  
  #Calculate the colSums
  
  ds.rowColCalc(x = "D",
                operation = "colSums", 
                newobj = "D.rowSums", 
                datasources = connections)
                
  #Clear the Datashield R sessions and logout
  datashield.logout(connections) 


## End(Not run)

datashield/dsBaseClient documentation built on May 16, 2023, 10:19 p.m.