Skip to content

Commit ecc27a8

Browse files
committed
Test bug fix
2 parents 8b9ef16 + 9a40d51 commit ecc27a8

51 files changed

Lines changed: 5399 additions & 477 deletions

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: 2 additions & 2 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-5
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.
@@ -11,5 +11,5 @@ Depends:
1111
Imports:
1212
fields,
1313
metafor
14-
RoxygenNote: 7.1.0
14+
RoxygenNote: 7.1.1
1515
Encoding: UTF-8

NAMESPACE

Lines changed: 6 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)
@@ -29,12 +30,15 @@ export(ds.dim)
2930
export(ds.exists)
3031
export(ds.exp)
3132
export(ds.glm)
33+
export(ds.glmPredict)
3234
export(ds.glmSLMA)
35+
export(ds.glmSummary)
3336
export(ds.glmerSLMA)
3437
export(ds.heatmapPlot)
3538
export(ds.histogram)
3639
export(ds.isNA)
3740
export(ds.isValid)
41+
export(ds.kurtosis)
3842
export(ds.length)
3943
export(ds.levels)
4044
export(ds.lexis)
@@ -81,6 +85,8 @@ export(ds.scatterPlot)
8185
export(ds.seq)
8286
export(ds.setDefaultOpals)
8387
export(ds.setSeed)
88+
export(ds.skewness)
89+
export(ds.sqrt)
8490
export(ds.subset)
8591
export(ds.subsetByClass)
8692
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.dataFrameSubset.R

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,54 @@ ds.dataFrameSubset<-function(df.name=NULL, V1.name=NULL, V2.name=NULL, Boolean.o
119119
stop("Please provide the name of the data.frame to be subsetted as a character string: eg 'xxx'", call.=FALSE)
120120
}
121121

122-
# check if user has provided the name of the column or scalar that holds V1
123-
if(is.null(V1.name)){
124-
stop("Please provide the name of the column or scalar that holds V1 as a character string: eg 'xxx' or '3'", call.=FALSE)
122+
# check if user has provided the name of the column or scalar that holds V1. If not
123+
# have they instead provided a non.null keep.cols or non.null rm.cols argument
124+
# in either of the latter cases then one needs to select all rows so
125+
# specify V1.name = "ONES" and this will specify a vector of 1s on the serverside
126+
# of length equal to dim[1] of the data.frame
127+
128+
if(is.null(keep.cols)&&is.null(rm.cols)&&is.null(V1.name))
129+
{
130+
return("Please provide the name of the column or scalar that holds V1 as a character string: eg 'xxx' or '3'", call.=FALSE)
125131
}
126-
127-
# check if user has provided the name of the column or scalar that holds V2
128-
if(is.null(V2.name)){
129-
stop("Please provide the name of the column or scalar that holds V2 as a character string: eg 'xxx' or '3'", call.=FALSE)
132+
133+
if((!is.null(keep.cols)||!is.null(rm.cols))&&is.null(V1.name))
134+
{
135+
V1.name<-"ONES"
136+
}
137+
138+
# check if user has provided the name of the column or scalar that holds V2. If not
139+
# have they instead provided a non.null keep.cols or non.null rm.cols argument
140+
# in either of the latter cases then one needs to select all rows so
141+
# specify V2.name = "ONES" and this will specify a vector of 1s on the serverside
142+
# of length equal to dim[1] of the data.frame
143+
144+
if(is.null(keep.cols)&&is.null(rm.cols)&&is.null(V2.name))
145+
{
146+
return("Please provide the name of the column or scalar that holds V2 as a character string: eg 'xxx' or '3'", call.=FALSE)
147+
}
148+
149+
if((!is.null(keep.cols)||!is.null(rm.cols))&&is.null(V2.name))
150+
{
151+
V2.name<-"ONES"
130152
}
131153

132-
# check if user has provided a Boolean operator in character format: eg '==' or '>=' or '<' or '!='
133-
if(is.null(Boolean.operator)){
134-
stop("Please provide a Boolean operator in character format: eg '==' or '>=' or '<' or '!='", call.=FALSE)
154+
if(is.null(keep.cols)&&is.null(rm.cols)&&is.null(Boolean.operator))
155+
{
156+
message1<-"Unless you are only subsetting columns, please provide a"
157+
message2<-"Boolean operator in character format: eg '==' or '>=' or '<' or '!='."
158+
message3<-"However, if either keep.cols or rm.cols is non-null because you want"
159+
message4<-"to subset columns and you specify both V1.name and V2.name as NULL (or 'ONES')"
160+
message5<-"and Boolean.operator as NULL,ds.dataFrameSubset will subset out"
161+
message6<-"the specified columns but will keep all rows."
162+
163+
error.message<-paste(message1,message2,message3,message4,message5,message6)
164+
return(error.message)
165+
}
166+
167+
if((!is.null(keep.cols)||!is.null(rm.cols))&&is.null(Boolean.operator))
168+
{
169+
Boolean.operator<-"=="
135170
}
136171

137172
#if keep.NAs is set as NULL convert to FALSE as otherwise the call to datashield.assign will fail

0 commit comments

Comments
 (0)