Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ import(DSI)
import(data.table)
importFrom(DSI,datashield.connections_find)
importFrom(cli,cli_abort)
importFrom(cli,cli_inform)
importFrom(cli,cli_verbatim)
importFrom(cli,cli_warn)
importFrom(stats,
as.formula,
na.omit,
Expand Down
24 changes: 7 additions & 17 deletions R/ds.Boole.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,32 +104,24 @@
#'
ds.Boole<-function(V1=NULL, V2=NULL, Boolean.operator=NULL, numeric.output=TRUE, na.assign="NA",newobj=NULL, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

# check if user has provided the name of the column or scalar that holds V1
if(is.null(V1)){
stop("Please provide the name of the column or scalar that holds V1!", call.=FALSE)
}
.checkArgProvided(V1, "the name of the column or scalar that holds V1")

# check if user has provided the name of a column or scalar holding V2 or has declared a scalar value: eg '3'
if(is.null(V2)){
stop("Please provide the name of a column or scalar holding V2 or declare a scalar in character format: eg '3'", call.=FALSE)
}
.checkArgProvided(V2, "the name of a column or scalar that holds V2")

# check if user has provided a Boolean operator in character format: eg '==' or '>=' or '<' or '!='
if(is.null(Boolean.operator)){
stop("Please provide a Boolean operator in character format: eg '==' or '>=' or '<' or '!='", call.=FALSE)
}
.checkArgProvided(Boolean.operator, "a Boolean operator in character format, such as '==' or '>='")

#check if na.assign has legal value
if(!(na.assign=="NA"||na.assign=="0"||na.assign=="1")){
stop("Error: na.assign must be a character string taking value 'NA', '0' or '1'- if <na.action> not specified default is 'NA'", call.=FALSE)
.abortInvalidChoice("na.assign", c("NA", "0", "1"))
}

# create a name by default if user did not provide a name for the new variable
if(is.null(newobj)){
newobj <- "boole.newobj"
}
newobj <- .resolveNewobjName(newobj, "boole.newobj")

#convert Boolean operator to numeric

Expand Down Expand Up @@ -163,9 +155,7 @@ ds.Boole<-function(V1=NULL, V2=NULL, Boolean.operator=NULL, numeric.output=TRUE,
}

# if no value spcified for output object, then specify a default
if(is.null(newobj)){
newobj <- paste0(V1,"_Boole")
}
newobj <- .resolveNewobjName(newobj, paste0(V1,"_Boole"))

# CALL THE MAIN SERVER SIDE FUNCTION
calltext <- call("BooleDS", V1, V2, BO.n, na.assign, numeric.output)
Expand Down
10 changes: 3 additions & 7 deletions R/ds.abs.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,13 @@
#'
ds.abs <- function(x=NULL, newobj=NULL, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

if(is.null(x)){
stop("Please provide the name of the input object!", call.=FALSE)
}
.checkArgProvided(x, "the name of the input object")

if(is.null(newobj)){
newobj <- "abs.newobj"
}
newobj <- .resolveNewobjName(newobj, "abs.newobj")

cally <- call("absDS", x)
DSI::datashield.assign(datasources, newobj, cally)

Check warning on line 83 in R/ds.abs.R

View workflow job for this annotation

GitHub Actions / R lint (lintr)

file=R/ds.abs.R,line=83,col=8,[namespace_linter] Don't use `::` to access datashield.assign, which is already imported from DSI.

}
10 changes: 3 additions & 7 deletions R/ds.asCharacter.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,13 @@
#'
ds.asCharacter <- function(x.name=NULL, newobj=NULL, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

if(is.null(x.name)){
stop("Please provide the name of the input vector!", call.=FALSE)
}
.checkArgProvided(x.name, "the name of the input vector")

if(is.null(newobj)){
newobj <- "ascharacter.newobj"
}
newobj <- .resolveNewobjName(newobj, "ascharacter.newobj")

calltext <- call("asCharacterDS", x.name)
DSI::datashield.assign(datasources, newobj, calltext)

Check warning on line 66 in R/ds.asCharacter.R

View workflow job for this annotation

GitHub Actions / R lint (lintr)

file=R/ds.asCharacter.R,line=66,col=7,[namespace_linter] Don't use `::` to access datashield.assign, which is already imported from DSI.

}
10 changes: 3 additions & 7 deletions R/ds.asDataMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,13 @@
#'
ds.asDataMatrix <- function(x.name=NULL, newobj=NULL, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

if(is.null(x.name)){
stop("Please provide the name of the input vector!", call.=FALSE)
}
.checkArgProvided(x.name, "the name of the input vector")

if(is.null(newobj)){
newobj <- "asdatamatrix.newobj"
}
newobj <- .resolveNewobjName(newobj, "asdatamatrix.newobj")

calltext <- call("asDataMatrixDS", x.name)
DSI::datashield.assign(datasources, newobj, calltext)

Check warning on line 65 in R/ds.asDataMatrix.R

View workflow job for this annotation

GitHub Actions / R lint (lintr)

file=R/ds.asDataMatrix.R,line=65,col=7,[namespace_linter] Don't use `::` to access datashield.assign, which is already imported from DSI.

}
6 changes: 2 additions & 4 deletions R/ds.asFactor.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,10 @@
ds.asFactor <- function(input.var.name=NULL, newobj.name=NULL, forced.factor.levels=NULL, fixed.dummy.vars=FALSE,
baseline.level=1, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

# check if user has provided the name of the column that holds the input variable
if(is.null(input.var.name)){
stop("Please provide the name of the variable that is to be converted to a factor e.g. 'varname'", call.=FALSE)
}
.checkArgProvided(input.var.name, "the name of the variable to convert to a factor")

# check if user has provided the name of the input variable in a correct character format
if(!is.character(input.var.name)){
Expand All @@ -208,7 +206,7 @@
#CALL THE FIRST SERVER SIDE FUNCTION (AN AGGREGATE FUNCTION)
#TO DETERMINE ALL OF THE LEVELS REQUIRED
calltext1 <- call("asFactorDS1", input.var.name)
all.levels <- DSI::datashield.aggregate(datasources, calltext1)

Check warning on line 209 in R/ds.asFactor.R

View workflow job for this annotation

GitHub Actions / R lint (lintr)

file=R/ds.asFactor.R,line=209,col=22,[namespace_linter] Don't use `::` to access datashield.aggregate, which is already imported from DSI.

failed.levels <- FALSE
for (levels in all.levels) {
Expand Down Expand Up @@ -237,7 +235,7 @@
all.unique.levels.transmit <- paste0(all.unique.levels, collapse=",")

calltext2 <- call("asFactorDS2", input.var.name, all.unique.levels.transmit, fixed.dummy.vars, baseline.level)
DSI::datashield.assign(datasources, newobj.name, calltext2)

Check warning on line 238 in R/ds.asFactor.R

View workflow job for this annotation

GitHub Actions / R lint (lintr)

file=R/ds.asFactor.R,line=238,col=8,[namespace_linter] Don't use `::` to access datashield.assign, which is already imported from DSI.

return(list(all.unique.levels=all.unique.levels))

Expand Down
6 changes: 2 additions & 4 deletions R/ds.asFactorSimple.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
#'
ds.asFactorSimple <- function(input.var.name=NULL, newobj.name=NULL, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

# check if user has provided the name of the column that holds the input variable
if(is.null(input.var.name)){
stop("Please provide the name of the variable that is to be converted to a factor e.g. 'varname'", call.=FALSE)
}
.checkArgProvided(input.var.name, "the name of the variable to convert to a factor")

# check if user has provided the name of the input variable in a correct character format
if(!is.character(input.var.name)){
Expand All @@ -44,7 +42,7 @@

#Call the only serverside function required for this simple version of asFactor
calltext0 <- call("asFactorSimpleDS", input.var.name)
DSI::datashield.assign(datasources, newobj.name, calltext0)

Check warning on line 45 in R/ds.asFactorSimple.R

View workflow job for this annotation

GitHub Actions / R lint (lintr)

file=R/ds.asFactorSimple.R,line=45,col=8,[namespace_linter] Don't use `::` to access datashield.assign, which is already imported from DSI.

}
#ds.asFactorSimple
10 changes: 3 additions & 7 deletions R/ds.asInteger.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,13 @@
#' @export
ds.asInteger <- function(x.name=NULL, newobj=NULL, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

if(is.null(x.name)){
stop("Please provide the name of the input vector!", call.=FALSE)
}
.checkArgProvided(x.name, "the name of the input vector")

if(is.null(newobj)){
newobj <- "asinteger.newobj"
}
newobj <- .resolveNewobjName(newobj, "asinteger.newobj")

calltext <- call("asIntegerDS", x.name)
DSI::datashield.assign(datasources, newobj, calltext)

Check warning on line 79 in R/ds.asInteger.R

View workflow job for this annotation

GitHub Actions / R lint (lintr)

file=R/ds.asInteger.R,line=79,col=8,[namespace_linter] Don't use `::` to access datashield.assign, which is already imported from DSI.

}
10 changes: 3 additions & 7 deletions R/ds.asList.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,11 @@
#'
ds.asList <- function(x.name=NULL, newobj=NULL, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

if(is.null(x.name)){
stop("Please provide the name of the input vector!", call.=FALSE)
}
.checkArgProvided(x.name, "the name of the input vector")

if(is.null(newobj)){
newobj <- "aslist.newobj"
}
newobj <- .resolveNewobjName(newobj, "aslist.newobj")

datashield.assign(datasources, newobj, call("asListDS", x.name))

Expand Down
10 changes: 3 additions & 7 deletions R/ds.asLogical.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,13 @@
#'
ds.asLogical <- function(x.name=NULL, newobj=NULL, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

if(is.null(x.name)){
stop("Please provide the name of the input vector!", call.=FALSE)
}
.checkArgProvided(x.name, "the name of the input vector")

if(is.null(newobj)){
newobj <- "aslogical.newobj"
}
newobj <- .resolveNewobjName(newobj, "aslogical.newobj")

calltext <- call("asLogicalDS", x.name)
DSI::datashield.assign(datasources, newobj, calltext)

Check warning on line 66 in R/ds.asLogical.R

View workflow job for this annotation

GitHub Actions / R lint (lintr)

file=R/ds.asLogical.R,line=66,col=7,[namespace_linter] Don't use `::` to access datashield.assign, which is already imported from DSI.

}
10 changes: 3 additions & 7 deletions R/ds.asMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,13 @@
#'
ds.asMatrix <- function(x.name=NULL, newobj=NULL, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

if(is.null(x.name)){
stop("Please provide the name of the input vector!", call.=FALSE)
}
.checkArgProvided(x.name, "the name of the input vector")

if(is.null(newobj)){
newobj <- "asmatrix.newobj"
}
newobj <- .resolveNewobjName(newobj, "asmatrix.newobj")

calltext <- call("asMatrixDS", x.name)
DSI::datashield.assign(datasources, newobj, calltext)

Check warning on line 68 in R/ds.asMatrix.R

View workflow job for this annotation

GitHub Actions / R lint (lintr)

file=R/ds.asMatrix.R,line=68,col=7,[namespace_linter] Don't use `::` to access datashield.assign, which is already imported from DSI.

}
10 changes: 3 additions & 7 deletions R/ds.asNumeric.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,11 @@
#'
ds.asNumeric <- function(x.name=NULL, newobj=NULL, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

if(is.null(x.name)){
stop("Please provide the name of the input vector!", call.=FALSE)
}
.checkArgProvided(x.name, "the name of the input vector")

if(is.null(newobj)){
newobj <- "asnumeric.newobj"
}
newobj <- .resolveNewobjName(newobj, "asnumeric.newobj")

calltext <- call("asNumericDS", x.name)
DSI::datashield.assign(datasources, newobj, calltext)
Expand Down
10 changes: 3 additions & 7 deletions R/ds.assign.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,12 @@
#'
ds.assign <- function(toAssign=NULL, newobj=NULL, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

if(is.null(toAssign)){
stop("Please give the name of object to assign or an expression to evaluate and assign.!\n", call.=FALSE)
}
.checkArgProvided(toAssign, "the name of the object to assign or an expression to evaluate")

# create a name by default if user did not provide a name for the new variable
if(is.null(newobj)){
newobj <- "assign.newobj"
}
newobj <- .resolveNewobjName(newobj, "assign.newobj")

# now do the business
DSI::datashield.assign(datasources, newobj, as.symbol(toAssign))
Expand Down
10 changes: 3 additions & 7 deletions R/ds.auc.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@
#'
ds.auc <- function(pred=NULL, y=NULL, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

# verify that 'pred' was set
if(is.null(pred)){
stop("Please provide the name of the vector with predicted values", call.=FALSE)
}
.checkArgProvided(pred, "the name of the vector of predicted values")

# verify that 'y' was set
if(is.null(y)){
stop("Please provide the name of the outcome variable", call.=FALSE)
}
.checkArgProvided(y, "the name of the outcome variable")

cally <- call('aucDS', pred, y)
output <- DSI::datashield.aggregate(datasources, cally)
Expand Down
6 changes: 3 additions & 3 deletions R/ds.boxPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@
ds.boxPlot <- function(x, variables = NULL, group = NULL, group2 = NULL, xlabel = "x axis",
ylabel = "y axis", type = "pooled", datasources = NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

# Ensure type is 'pooled' or 'split'
if((length(type) == 1) && (! any(type %in% c("pooled", "split")))){
stop("[type] can only be set to 'pooled' or 'split'")
.abortInvalidChoice("type", c("pooled", "split"))
}

# Determine class of x for dispatch
cls <- datashield.aggregate(datasources, call("classDS", x))
.checkClassConsistency(lapply(cls, function(study.class) list(class = study.class)), object_name = x)
.checkClassConsistency(lapply(cls, function(study.class) list(class = study.class)), objectName = x)
cls <- unique(unlist(cls))

if(!any(c("numeric", "data.frame") %in% cls)){
Expand Down
4 changes: 2 additions & 2 deletions R/ds.boxPlotGG.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

ds.boxPlotGG <- function(x, group = NULL, group2 = NULL, xlabel = "x axis", ylabel = "y axis", type = "pooled", datasources = NULL){
x_var <- lower <- upper <- ymin <- ymax <- middle <- fill <- NULL
datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

plot_data <- datashield.aggregate(datasources, call("boxPlotGGDS", data_table.name=x, group=group, group2=group2))

Expand Down Expand Up @@ -132,7 +132,7 @@ ds.boxPlotGG <- function(x, group = NULL, group2 = NULL, xlabel = "x axis", ylab
plt <- do.call(gridExtra::grid.arrange, plt)

}
else{stop("Invalid type")}
else{.abortInvalidChoice("type", c("pooled", "split"))}

return(plt)

Expand Down
2 changes: 1 addition & 1 deletion R/ds.boxPlotGG_data_Treatment.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

ds.boxPlotGG_data_Treatment <- function(table, variables, group = NULL, group2 = NULL, datasources = NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

datashield.assign.expr(datasources, "boxPlotRawData", call("boxPlotGG_data_TreatmentDS", table.name = table, variables = variables, group = group, group2 = group2))

Expand Down
2 changes: 1 addition & 1 deletion R/ds.boxPlotGG_data_Treatment_numeric.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

ds.boxPlotGG_data_Treatment_numeric <- function(vector, datasources = NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

datashield.assign.expr(datasources, "boxPlotRawDataNumeric", call("boxPlotGG_data_Treatment_numericDS", vector.name = vector))

Expand Down
2 changes: 1 addition & 1 deletion R/ds.boxPlotGG_numeric.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

ds.boxPlotGG_numeric <- function(x, xlabel = "x axis", ylabel = "y axis", type = "pooled", datasources = NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

ds.boxPlotGG_data_Treatment_numeric(x, datasources)

Expand Down
2 changes: 1 addition & 1 deletion R/ds.boxPlotGG_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ds.boxPlotGG_table <- function(x, variables, group = NULL, group2 = NULL, xlabel = "x axis",
ylabel = "y axis", type = "pooled", datasources = NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

ds.boxPlotGG_data_Treatment(x, variables, group, group2, datasources)

Expand Down
22 changes: 6 additions & 16 deletions R/ds.bp_standards.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,22 @@
ds.bp_standards <- function(sex=NULL, age=NULL, height=NULL, bp=NULL, systolic=TRUE,
newobj=NULL, datasources=NULL){

datasources <- .set_datasources(datasources)
datasources <- .resolveDatasources(datasources)

# verify that 'sex' was set
if(is.null(sex)){
stop("Please provide the name of the sex variable", call.=FALSE)
}
.checkArgProvided(sex, "the name of the sex variable")

# verify that 'age' was set
if(is.null(age)){
stop("Please provide the name of the age in months variable", call.=FALSE)
}
.checkArgProvided(age, "the name of the age in months variable")

# verify that 'height' was set
if(is.null(height)){
stop("Please provide the name of the height in cm variable", call.=FALSE)
}
.checkArgProvided(height, "the name of the height in cm variable")

# verify that 'bp' was set
if(is.null(bp)){
stop("Please provide the name of the blood pressure variable", call.=FALSE)
}
.checkArgProvided(bp, "the name of the blood pressure variable")

# if no output object specified then provide a default name
if(is.null(newobj)){
newobj <- "bp.newobj"
}
newobj <- .resolveNewobjName(newobj, "bp.newobj")

# call the server-side assign function
cally <- call('bp_standardsDS', sex, age, height, bp, systolic)
Expand Down
Loading
Loading