Skip to content

Commit f1bcb11

Browse files
Merge pull request #295 from datashield/v6.1
Update to v6.1
2 parents cda41b6 + 38a1ab5 commit f1bcb11

153 files changed

Lines changed: 10591 additions & 21411 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
^LICENSE.md$
55
^azure-pipelines\.yml$
66
^azure-pipelines_site\.pp$
7+
^azure-pipelines_site-dsdanger\.pp$
78
^azure-pipelines_check\.Rout$
89
^azure-pipelines_test\.Rout$
910
^checkDocumentationUpdated\.sh$

DESCRIPTION

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: dsBaseClient
22
Title: DataSHIELD Client Functions
3-
Version: 6.0.1
3+
Version: 6.1.0
44
Author: DataSHIELD Developers <datashield@newcastle.ac.uk>
55
Maintainer: DataSHIELD Developers <datashield@newcastle.ac.uk>
66
Description: DataSHIELD client functions for the client side.
@@ -10,6 +10,9 @@ Depends:
1010
DSI (>= 1.1.0)
1111
Imports:
1212
fields,
13-
metafor
14-
RoxygenNote: 7.1.0
13+
metafor,
14+
ggplot2,
15+
gridExtra,
16+
data.table
17+
RoxygenNote: 7.1.1
1518
Encoding: UTF-8

NAMESPACE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(ds.Boole)
4+
export(ds.abs)
45
export(ds.asCharacter)
56
export(ds.asDataMatrix)
67
export(ds.asFactor)
@@ -10,6 +11,7 @@ export(ds.asLogical)
1011
export(ds.asMatrix)
1112
export(ds.asNumeric)
1213
export(ds.assign)
14+
export(ds.boxPlot)
1315
export(ds.c)
1416
export(ds.cbind)
1517
export(ds.changeRefGroup)
@@ -28,13 +30,17 @@ export(ds.densityGrid)
2830
export(ds.dim)
2931
export(ds.exists)
3032
export(ds.exp)
33+
export(ds.getWGSR)
3134
export(ds.glm)
35+
export(ds.glmPredict)
3236
export(ds.glmSLMA)
37+
export(ds.glmSummary)
3338
export(ds.glmerSLMA)
3439
export(ds.heatmapPlot)
3540
export(ds.histogram)
3641
export(ds.isNA)
3742
export(ds.isValid)
43+
export(ds.kurtosis)
3844
export(ds.length)
3945
export(ds.levels)
4046
export(ds.lexis)
@@ -81,6 +87,8 @@ export(ds.scatterPlot)
8187
export(ds.seq)
8288
export(ds.setDefaultOpals)
8389
export(ds.setSeed)
90+
export(ds.skewness)
91+
export(ds.sqrt)
8492
export(ds.subset)
8593
export(ds.subsetByClass)
8694
export(ds.summary)

R/ds.abs.R

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#'
2+
#' @title Computes the absolute values of a variable
3+
#' @description Computes the absolute values for a specified numeric or integer vector.
4+
#' This function is similar to R function \code{abs}.
5+
#' @details The function calls the server-side function \code{absDS} that computes the
6+
#' absolute values of the elements of a numeric or integer vector and assigns a new vector
7+
#' with those absolute values on the server-side. The name of the new generated vector is
8+
#' specified by the user through the argument \code{newobj}, otherwise is named by default to
9+
#' \code{abs.newobj}.
10+
#' @param x a character string providing the name of a numeric or an integer vector.
11+
#' @param newobj a character string that provides the name for the output variable
12+
#' that is stored on the data servers. Default name is set to \code{abs.newobj}.
13+
#' @param datasources a list of \code{\link{DSConnection-class}} objects obtained after login.
14+
#' If the \code{datasources} argument is not specified the default set of connections will be
15+
#' used: see \code{\link{datashield.connections_default}}.
16+
#' @return \code{ds.abs} assigns a vector for each study that includes the absolute values of
17+
#' the input numeric or integer vector specified in the argument \code{x}. The created vectors
18+
#' are stored in the servers.
19+
#' @author Demetris Avraam for DataSHIELD Development Team
20+
#' @export
21+
#' @examples
22+
#' \dontrun{
23+
#'
24+
#' # Connecting to the Opal servers
25+
#'
26+
#' require('DSI')
27+
#' require('DSOpal')
28+
#' require('dsBaseClient')
29+
#'
30+
#' builder <- DSI::newDSLoginBuilder()
31+
#' builder$append(server = "study1",
32+
#' url = "http://192.168.56.100:8080/",
33+
#' user = "administrator", password = "datashield_test&",
34+
#' table = "CNSIM.CNSIM1", driver = "OpalDriver")
35+
#' builder$append(server = "study2",
36+
#' url = "http://192.168.56.100:8080/",
37+
#' user = "administrator", password = "datashield_test&",
38+
#' table = "CNSIM.CNSIM2", driver = "OpalDriver")
39+
#' builder$append(server = "study3",
40+
#' url = "http://192.168.56.100:8080/",
41+
#' user = "administrator", password = "datashield_test&",
42+
#' table = "CNSIM.CNSIM3", driver = "OpalDriver")
43+
#'
44+
#' logindata <- builder$build()
45+
#'
46+
#' # Log onto the remote Opal training servers
47+
#' connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D")
48+
#'
49+
#' # Example 1: Generate a normally distributed variable with zero mean and variance equal
50+
#' # to one and then get their absolute values
51+
#' ds.rNorm(samp.size=100, mean=0, sd=1, newobj='var.norm', datasources=connections)
52+
#' # check the quantiles
53+
#' ds.summary(x='var.norm', datasources=connections)
54+
#' ds.abs(x='var.norm', newobj='var.norm.abs', datasources=connections)
55+
#' # check now the changes in the quantiles
56+
#' ds.summary(x='var.norm.abs', datasources=connections)
57+
#'
58+
#' # Example 2: Generate a sequence of negative integer numbers from -200 to -100
59+
#' # and then get their absolute values
60+
#' ds.seq(FROM.value.char = '-200', TO.value.char = '-100', BY.value.char = '1',
61+
#' newobj='negative.integers', datasources=connections)
62+
#' # check the quantiles
63+
#' ds.summary(x='negative.integers', datasources=connections)
64+
#' ds.abs(x='negative.integers', newobj='positive.integers', datasources=connections)
65+
#' # check now the changes in the quantiles
66+
#' ds.summary(x='positive.integers', datasources=connections)
67+
#'
68+
#' # clear the Datashield R sessions and logout
69+
#' datashield.logout(connections)
70+
#'
71+
#' }
72+
#'
73+
ds.abs <- function(x=NULL, newobj=NULL, datasources=NULL){
74+
75+
# look for DS connections
76+
if(is.null(datasources)){
77+
datasources <- datashield.connections_find()
78+
}
79+
80+
if(is.null(x)){
81+
stop("Please provide the name of the input object!", call.=FALSE)
82+
}
83+
84+
# the input variable might be given as column table (i.e. D$x)
85+
# or just as a vector not attached to a table (i.e. x)
86+
# we have to make sure the function deals with each case
87+
xnames <- extract(x)
88+
varname <- xnames$elements
89+
obj2lookfor <- xnames$holders
90+
91+
# check if the input object(s) is(are) defined in all the studies
92+
if(is.na(obj2lookfor)){
93+
defined <- isDefined(datasources, varname)
94+
}else{
95+
defined <- isDefined(datasources, obj2lookfor)
96+
}
97+
98+
# call the internal function that checks the input object is of the same class in all studies.
99+
typ <- checkClass(datasources, x)
100+
101+
# call the internal function that checks the input object(s) is(are) of the same class in all studies.
102+
if(!('numeric' %in% typ) && !('integer' %in% typ)){
103+
stop("Only objects of type 'numeric' or 'integer' are allowed.", call.=FALSE)
104+
}
105+
106+
# create a name by default if the user did not provide a name for the new variable
107+
if(is.null(newobj)){
108+
newobj <- "abs.newobj"
109+
}
110+
111+
# call the server side function that does the operation
112+
cally <- call("absDS", x)
113+
DSI::datashield.assign(datasources, newobj, cally)
114+
115+
# check that the new object has been created and display a message accordingly
116+
finalcheck <- isAssigned(datasources, newobj)
117+
118+
}

R/ds.boxPlot.R

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#' @title Draw boxplot
2+
#'
3+
#' @description Draw boxplot with data on the study servers (data frames or numeric vectors) with the option
4+
#' of grouping using categorical variables on the dataset (only for data frames)
5+
#'
6+
#' @param x \code{character} Name of the data frame (or numeric vector) on the server side that
7+
#' holds the information to be plotted
8+
#' @param variables \code{character vector} Name of the column(s) of the data frame to include on the boxplot
9+
#' @param group \code{character} (default \code{NULL}) Name of the first grouping variable.
10+
#' @param group2 \code{character} (default \code{NULL}) Name of the second grouping variable.
11+
#' @param xlabel \code{caracter} (default \code{"x axis"}) Label to put on the x axis of the plot
12+
#' @param ylabel \code{caracter} (default \code{"y axis"}) Label to put on the y axis of the plot
13+
#' @param type \code{character} Return a pooled plot (\code{"pooled"}) or a split plot (one for each study server
14+
#' \code{"split"})
15+
#' @param datasources a list of \code{\link{DSConnection-class}} (default \code{NULL}) objects obtained after login
16+
#'
17+
#' @return \code{ggplot} object
18+
#' @export
19+
20+
ds.boxPlot <- function(x, variables = NULL, group = NULL, group2 = NULL, xlabel = "x axis",
21+
ylabel = "y axis", type = "pooled", datasources = NULL){
22+
23+
if (is.null(datasources)) {
24+
datasources <- DSI::datashield.connections_find()
25+
}
26+
27+
isDefined(datasources, x)
28+
cls <- checkClass(datasources, x)
29+
30+
if(any(cls %in% c("data.frame"))){
31+
ds.boxPlotGG_table(x, variables, group, group2, xlabel, ylabel, type, datasources)
32+
}
33+
else if(any(cls %in% c("numeric"))){
34+
ds.boxPlotGG_numeric(x, xlabel, ylabel, type, datasources)
35+
}
36+
else(stop("The selected object is not a data frame nor a numerical vector"))
37+
38+
}

0 commit comments

Comments
 (0)