Skip to content

Commit

Permalink
Merge pull request #40 from datashield/v5.1-dev
Browse files Browse the repository at this point in the history
V5.1 dev
  • Loading branch information
OllyButters committed Jan 7, 2020
2 parents 16b0aa4 + 3217b94 commit c8b8429
Show file tree
Hide file tree
Showing 39 changed files with 573 additions and 798 deletions.
16 changes: 8 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dsBase
Title: DataSHIELD server site base functions
Version: 5.0.0
Version: 5.1.0
Author: DataSHIELD Developers <datashield@newcastle.ac.uk>
Maintainer: DataSHIELD Developers <datashield@newcastle.ac.uk>
License: GPL-3
Expand All @@ -17,7 +17,6 @@ AggregateMethods:
dataFrameSubsetDS1,
densityGridDS,
dimDS,
dimDS,
glmDS1,
glmDS2,
glmSLMADS1,
Expand All @@ -32,8 +31,6 @@ AggregateMethods:
listDisclosureSettingsDS,
matrixDetDS1,
meanDS,
meanDS,
meanSdGpDS,
meanSdGpDS,
messageDS,
namesDS,
Expand All @@ -50,10 +47,10 @@ AggregateMethods:
tapplyDS,
testObjExistsDS,
tTestFDS2,
unListDS,
varDS,
class=base::class,
colnames=base::colnames,
cor.test=stats::cor.test,
dim=base::dim,
exists=base::exists,
is.character=base::is.character,
Expand All @@ -64,7 +61,8 @@ AggregateMethods:
length=base::length,
levels=base::levels,
ls=base::ls,
NROW=base::NROW
NROW=base::NROW,
t.test=stats::t.test
AssignMethods:
asCharacterDS,
asDataMatrixDS,
Expand All @@ -74,13 +72,13 @@ AssignMethods:
asListDS,
asLogicalDS,
asMatrixDS,
asMatrixDS,
asNumericDS,
BooleDS,
cbindDS,
cDS,
changeRefGroupDS,
dataFrameDS,
dataFrameFillDS,
dataFrameSortDS,
dataFrameSubsetDS2,
listDS,
Expand Down Expand Up @@ -109,9 +107,11 @@ AssignMethods:
subsetByClassDS,
subsetDS,
tapplyDS.assign,
unListDS,
as.character=base::as.character,
as.null=base::as.null,
as.numeric=base::as.numeric,
attach=base::attach,
c=base::c,
cbind=base::cbind,
complete.cases=stats::complete.cases,
Expand All @@ -131,4 +131,4 @@ Options:
default.nfilter.tab=3,
default.nfilter.noise=0.25,
default.nfilter.levels=0.33
RoxygenNote: 6.1.1
RoxygenNote: 7.0.2
3 changes: 1 addition & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(BooleDS)
export(alphaPhiDS)
export(asCharacterDS)
export(asDataMatrixDS)
export(asFactorDS1)
Expand All @@ -18,6 +17,7 @@ export(checkNegValueDS)
export(corDS)
export(covDS)
export(dataFrameDS)
export(dataFrameFillDS)
export(dataFrameSortDS)
export(dataFrameSubsetDS1)
export(dataFrameSubsetDS2)
Expand Down Expand Up @@ -67,7 +67,6 @@ export(replaceNaDS)
export(rmDS)
export(rowColCalcDS)
export(scatterPlotDS)
export(scoreVectDS)
export(seqDS)
export(setSeedDS)
export(subsetByClassDS)
Expand Down
135 changes: 0 additions & 135 deletions R/alphaPhiDS.R

This file was deleted.

2 changes: 1 addition & 1 deletion R/asIntegerDS.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' \code{ds.asInteger}.
#' @return the object specified by the <newobj> argument (or its default name
#' <x.name>.int) which is written to the serverside. For further
#' details see help on the clientside function \type{ds.asInteger}.
#' details see help on the clientside function \code{ds.asInteger}.
#' @author Amadou Gaye, Paul Burton, Demetris Avraam, for DataSHIELD Development Team
#' @export
#'
Expand Down
12 changes: 10 additions & 2 deletions R/cDS.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@
#'
cDS <- function (objs) {
# this filter sets the minimum number of observations that are allowed
nfilter <- setFilterDS()

#############################################################
# MODULE 1: CAPTURE THE nfilter SETTINGS
thr <- listDisclosureSettingsDS()
nfilter.tab <- as.numeric(thr$nfilter.tab)
#nfilter.glm <- as.numeric(thr$nfilter.glm)
#nfilter.subset <- as.numeric(thr$nfilter.subset)
#nfilter.string <- as.numeric(thr$nfilter.string)
#############################################################

x <- unlist(objs)

# check if the output is valid and output accordingly
if(length(x) < nfilter){
if(length(x) < nfilter.tab){
if(length(x == 0)){
x <- c()
}else{
Expand Down
48 changes: 48 additions & 0 deletions R/dataFrameFillDS.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#'
#' @title dataFrameFillDS
#' @description An assign function called by the clientside ds.dataFrameFill function.
#' @details This function checks if each study has all the variables compared to the other studies
#' in the analysis. If a study does not have some of the variables, the function generates those
#' variables as vectors of missing values and combines them as columns to the input data frame.
#' Then, the "complete" in terms of the columns dataframe is saved in each server with a name
#' specified by the argument \code{newobj} on the clientside.
#' @param df.name a character string representing the name of the input data frame that will be
#' filled with extra columns with missing values if a number of variables is missing from it
#' compared to the data frames of the other studies used in the analysis.
#' @param allNames.transmit unique names of all the variables that are included in the input
#' data frames from all the used datasources.
#' @return Nothing is returned to the client. The generated object is written to the serverside.
#' @author Demetris Avraam for DataSHIELD Development Team
#' @export
#'
dataFrameFillDS <- function(df.name, allNames.transmit){

datatext <- paste0("data.frame(",df.name,")")
data <- eval(parse(text=datatext))

if(!is.null(allNames.transmit)){
allNames <- unlist(strsplit(allNames.transmit, split=","))
}else{
allNames <- NULL
}

study.colnames <- colnames(data)
missingVars <- allNames[-which(allNames %in% study.colnames)]

numRows <- dim(data)[1]
numCols <- length(missingVars)

mat.new <- matrix(NA, ncol=numCols, nrow=numRows)

df.new <- as.data.frame(mat.new)
colnames(df.new) <- missingVars
df.new <- lapply(df.new, as.numeric)

df.out <- cbind(data, df.new)

return(df.out)

}
# ASSIGN FUNCTION
# dataFrameFillDS

0 comments on commit c8b8429

Please sign in to comment.