Now you have written your function, lets see if it works. The following script attempts to call the two newly written client-side function dsFunLevelsClient
, which will call the server-side function dsFunLevels
.
library(DSLite)
library(devtools)
data("iris")
devtools::load_all("path/to/dsExample")
devtools::load_all("path/to/dsExampleClient")
dslite.server <- newDSLiteServer(
tables = list(
iris = iris
)
)
dslite.server$config(defaultDSConfiguration(include=c("dsBase", "dsExample")))
dslite.server$aggregateMethod("funLevelsDS", "funLevelsDS")
dslite.server$aggregateMethod("listDisclosureSettingsDS", "listDisclosureSettingsDS")
dslite.server$aggregateMethod("checkPermissivePrivacyControlLevel", "checkPermissivePrivacyControlLevel")
options(
datashield.privacyControlLevel = "banana",
nfilter.tab = 3,
nfilter.subset = 3,
nfilter.glm = 0.33,
nfilter.string = 80,
nfilter.stringShort = 20,
nfilter.kNN = 3,
nfilter.levels.density = 0.33,
nfilter.levels.max = 40,
nfilter.noise = 0.25,
nfilter.privacy.old = 5
)
builder <- DSI::newDSLoginBuilder()
builder$append(
server = "server_1",
url = "dslite.server",
table = "iris",
driver = "DSLiteDriver"
)
builder$append(
server = "server_2",
url = "dslite.server",
table = "iris",
driver = "DSLiteDriver"
)
logindata <- builder$build()
conns <- DSI::datashield.login(logins = logindata, assign = FALSE)
datashield.assign.table(
conns = conns,
table = "iris",
symbol = "iris")
ds.funLevels(x = "iris$Species", fun_message = "HappyFriday")
$server_1
[1] "HappyFriday : setosa, versicolor, virginica"
$server_2
[1] "HappyFriday : setosa, versicolor, virginica"
Congratulations, your first DataSHIELD function works!