DataSHIELD is a platform primarily used to analyse data from multiple datasources. When you initially log in, you specify which datasources you want to access. All these datasources are then available for analyis, and as a default DataSHIELD functions will use all datasources.
library(dsBaseClient)
However, there maybe times you only want to run a function for some of the available datasources. To control which datasources are used, you use the datasources
argument. For example, if you only want to use the datasources named 'server1', you can specify this by adding the name of the datasource you want to use in square brackets:
ds.ls(datasources = conns["server1"])
## $server1
## $server1$environment.searched
## [1] "R_GlobalEnv"
##
## $server1$objects.found
## [1] "cnsim" "dasim" "depression" "survival" "titanic"
You can also specify to remove a datasource using !
:
ds.ls(datasources = conns[names(conns) != "server1"])
## $server2
## $server2$environment.searched
## [1] "R_GlobalEnv"
##
## $server2$objects.found
## [1] "cnsim" "dasim" "depression" "survival" "titanic"
If you want to specify multiple datasources, use the %in%
operator.
ds.ls(datasources = conns[names(conns) %in% c("server1", "server2")])
## $server1
## $server1$environment.searched
## [1] "R_GlobalEnv"
##
## $server1$objects.found
## [1] "cnsim" "dasim" "depression" "survival" "titanic"
##
##
## $server2
## $server2$environment.searched
## [1] "R_GlobalEnv"
##
## $server2$objects.found
## [1] "cnsim" "dasim" "depression" "survival" "titanic"
In this case it is only for illustration, as we only have two datasources and are selecting them all. Using all datasources is the default:
ds.ls()
## $server1
## $server1$environment.searched
## [1] "R_GlobalEnv"
##
## $server1$objects.found
## [1] "cnsim" "dasim" "depression" "survival" "titanic"
##
##
## $server2
## $server2$environment.searched
## [1] "R_GlobalEnv"
##
## $server2$objects.found
## [1] "cnsim" "dasim" "depression" "survival" "titanic"
datashield.logout(conns)