From 5e5342c05303b584eba046a758f634cf0495c593 Mon Sep 17 00:00:00 2001 From: Stuart Wheater Date: Mon, 19 Aug 2019 12:54:59 +0100 Subject: [PATCH 1/3] Added 'dataFrameFillDS' --- DESCRIPTION | 1 + NAMESPACE | 1 + R/dataFrameFillDS.R | 48 ++++++++++++++++++++++++++++++++++++++++++ man/dataFrameFillDS.Rd | 32 ++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 R/dataFrameFillDS.R create mode 100644 man/dataFrameFillDS.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 442a942a..24ce2f4b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -81,6 +81,7 @@ AssignMethods: cDS, changeRefGroupDS, dataFrameDS, + dataFrameFillDS, dataFrameSortDS, dataFrameSubsetDS2, listDS, diff --git a/NAMESPACE b/NAMESPACE index 9a329b7f..cecaa718 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,6 +18,7 @@ export(checkNegValueDS) export(corDS) export(covDS) export(dataFrameDS) +export(dataFrameFillDS) export(dataFrameSortDS) export(dataFrameSubsetDS1) export(dataFrameSubsetDS2) diff --git a/R/dataFrameFillDS.R b/R/dataFrameFillDS.R new file mode 100644 index 00000000..9c318235 --- /dev/null +++ b/R/dataFrameFillDS.R @@ -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 + diff --git a/man/dataFrameFillDS.Rd b/man/dataFrameFillDS.Rd new file mode 100644 index 00000000..858affd8 --- /dev/null +++ b/man/dataFrameFillDS.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dataFrameFillDS.R +\name{dataFrameFillDS} +\alias{dataFrameFillDS} +\title{dataFrameFillDS} +\usage{ +dataFrameFillDS(df.name, allNames.transmit) +} +\arguments{ +\item{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.} + +\item{allNames.transmit}{unique names of all the variables that are included in the input +data frames from all the used datasources.} +} +\value{ +Nothing is returned to the client. The generated object is written to the serverside. +} +\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. +} +\author{ +Demetris Avraam for DataSHIELD Development Team +} From bce0cf9cd1be9ba1b2419e0d77ee63cf6bcd7f9e Mon Sep 17 00:00:00 2001 From: Stuart Wheater Date: Mon, 19 Aug 2019 13:25:50 +0100 Subject: [PATCH 2/3] Converted to unix file --- R/dataFrameFillDS.R | 96 ++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/R/dataFrameFillDS.R b/R/dataFrameFillDS.R index 9c318235..b7e22835 100644 --- a/R/dataFrameFillDS.R +++ b/R/dataFrameFillDS.R @@ -1,48 +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 - +#' +#' @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 + From 85994c12058c77216c434c7235bc1818c2260cb1 Mon Sep 17 00:00:00 2001 From: Stuart Wheater Date: Thu, 2 Jan 2020 14:14:00 +0000 Subject: [PATCH 3/3] Update documents due to use of RoxygenNote-7.0.2 --- DESCRIPTION | 2 +- man/BooleDS.Rd | 9 +++++++-- man/asFactorDS2.Rd | 8 ++++++-- man/dataFrameDS.Rd | 12 +++++++++--- man/dataFrameSortDS.Rd | 10 +++++++--- man/dataFrameSubsetDS1.Rd | 12 +++++++++--- man/dataFrameSubsetDS2.Rd | 12 +++++++++--- man/densityGridDS.Rd | 12 ++++++++++-- man/lexisDS2.Rd | 12 ++++++++++-- man/matrixDS.Rd | 3 +-- man/mergeDS.Rd | 14 ++++++++++++-- man/reShapeDS.Rd | 12 ++++++++++-- man/recodeValuesDS1.Rd | 7 +++++-- man/recodeValuesDS2.Rd | 11 ++++++++--- man/seqDS.Rd | 9 +++++++-- man/subsetDS.Rd | 11 +++++++++-- 16 files changed, 120 insertions(+), 36 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 449eb141..818500f6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/man/BooleDS.Rd b/man/BooleDS.Rd index 92eaa312..50eb4197 100644 --- a/man/BooleDS.Rd +++ b/man/BooleDS.Rd @@ -4,8 +4,13 @@ \alias{BooleDS} \title{BooleDS} \usage{ -BooleDS(V1.name = NULL, V2.name = NULL, Boolean.operator.n = NULL, - na.assign.text, numeric.output = TRUE) +BooleDS( + V1.name = NULL, + V2.name = NULL, + Boolean.operator.n = NULL, + na.assign.text, + numeric.output = TRUE +) } \arguments{ \item{V1.name}{A character string specifying the name of the vector to which the diff --git a/man/asFactorDS2.Rd b/man/asFactorDS2.Rd index b4d3843f..b97f3cc4 100644 --- a/man/asFactorDS2.Rd +++ b/man/asFactorDS2.Rd @@ -4,8 +4,12 @@ \alias{asFactorDS2} \title{Converts a numeric vector into a factor} \usage{ -asFactorDS2(input.var.name = NULL, all.unique.levels.transmit = NULL, - fixed.dummy.vars = NULL, baseline.level = NULL) +asFactorDS2( + input.var.name = NULL, + all.unique.levels.transmit = NULL, + fixed.dummy.vars = NULL, + baseline.level = NULL +) } \arguments{ \item{input.var.name}{the name of the variable that is to be converted to a factor.} diff --git a/man/dataFrameDS.Rd b/man/dataFrameDS.Rd index 0cc8026a..69be3d71 100644 --- a/man/dataFrameDS.Rd +++ b/man/dataFrameDS.Rd @@ -4,9 +4,15 @@ \alias{dataFrameDS} \title{dataFrameDS called by ds.dataFrame} \usage{ -dataFrameDS(vectors = NULL, r.names = NULL, ch.rows = FALSE, - ch.names = TRUE, clnames = NULL, strAsFactors = TRUE, - completeCases = FALSE) +dataFrameDS( + vectors = NULL, + r.names = NULL, + ch.rows = FALSE, + ch.names = TRUE, + clnames = NULL, + strAsFactors = TRUE, + completeCases = FALSE +) } \arguments{ \item{vectors}{a list which contains the elemental components to combine. diff --git a/man/dataFrameSortDS.Rd b/man/dataFrameSortDS.Rd index c0a574f3..c419ebf5 100644 --- a/man/dataFrameSortDS.Rd +++ b/man/dataFrameSortDS.Rd @@ -4,9 +4,13 @@ \alias{dataFrameSortDS} \title{dataFrameSortDS called by ds.dataFrameSort} \usage{ -dataFrameSortDS(df.text = NULL, sort.key.text = NULL, - sort.descending = FALSE, sort.alphabetic = FALSE, - sort.numeric = FALSE) +dataFrameSortDS( + df.text = NULL, + sort.key.text = NULL, + sort.descending = FALSE, + sort.alphabetic = FALSE, + sort.numeric = FALSE +) } \arguments{ \item{df.text}{a character string providing the name for the data.frame diff --git a/man/dataFrameSubsetDS1.Rd b/man/dataFrameSubsetDS1.Rd index 29a5bb6b..25002918 100644 --- a/man/dataFrameSubsetDS1.Rd +++ b/man/dataFrameSubsetDS1.Rd @@ -4,9 +4,15 @@ \alias{dataFrameSubsetDS1} \title{dataFrameSubsetDS1 an aggregate function called by ds.dataFrameSubset} \usage{ -dataFrameSubsetDS1(df.name = NULL, V1.name = NULL, V2.name = NULL, - Boolean.operator.n = NULL, keep.cols = NULL, rm.cols = NULL, - keep.NAs = NULL) +dataFrameSubsetDS1( + df.name = NULL, + V1.name = NULL, + V2.name = NULL, + Boolean.operator.n = NULL, + keep.cols = NULL, + rm.cols = NULL, + keep.NAs = NULL +) } \arguments{ \item{df.name}{a character string providing the name for the data.frame diff --git a/man/dataFrameSubsetDS2.Rd b/man/dataFrameSubsetDS2.Rd index 89eae803..fdc6c5ee 100644 --- a/man/dataFrameSubsetDS2.Rd +++ b/man/dataFrameSubsetDS2.Rd @@ -4,9 +4,15 @@ \alias{dataFrameSubsetDS2} \title{dataFrameSubsetDS2 an assign function called by ds.dataFrameSubset} \usage{ -dataFrameSubsetDS2(df.name = NULL, V1.name = NULL, V2.name = NULL, - Boolean.operator.n = NULL, keep.cols = NULL, rm.cols = NULL, - keep.NAs = NULL) +dataFrameSubsetDS2( + df.name = NULL, + V1.name = NULL, + V2.name = NULL, + Boolean.operator.n = NULL, + keep.cols = NULL, + rm.cols = NULL, + keep.NAs = NULL +) } \arguments{ \item{df.name}{a character string providing the name for the data.frame diff --git a/man/densityGridDS.Rd b/man/densityGridDS.Rd index 07a88b50..ea18a3b0 100644 --- a/man/densityGridDS.Rd +++ b/man/densityGridDS.Rd @@ -4,8 +4,16 @@ \alias{densityGridDS} \title{Generates a density grid with or without a priori defined limits} \usage{ -densityGridDS(xvect, yvect, limits = FALSE, x.min = NULL, - x.max = NULL, y.min = NULL, y.max = NULL, numints = 20) +densityGridDS( + xvect, + yvect, + limits = FALSE, + x.min = NULL, + x.max = NULL, + y.min = NULL, + y.max = NULL, + numints = 20 +) } \arguments{ \item{xvect}{a numerical vector} diff --git a/man/lexisDS2.Rd b/man/lexisDS2.Rd index 512a10f8..682f3545 100644 --- a/man/lexisDS2.Rd +++ b/man/lexisDS2.Rd @@ -4,8 +4,16 @@ \alias{lexisDS2} \title{lexisDS2} \usage{ -lexisDS2(datatext = NULL, intervalWidth, maxmaxtime, idCol, entryCol, - exitCol, statusCol, vartext = NULL) +lexisDS2( + datatext = NULL, + intervalWidth, + maxmaxtime, + idCol, + entryCol, + exitCol, + statusCol, + vartext = NULL +) } \arguments{ \item{datatext}{a clientside provided character string specifying the data.frame diff --git a/man/matrixDS.Rd b/man/matrixDS.Rd index 57f0733e..ddc20e03 100644 --- a/man/matrixDS.Rd +++ b/man/matrixDS.Rd @@ -4,8 +4,7 @@ \alias{matrixDS} \title{matrixDS assign function called by ds.matrix} \usage{ -matrixDS(mdata.transmit, from, nrows.transmit, ncols.transmit, byrow, - dimnames) +matrixDS(mdata.transmit, from, nrows.transmit, ncols.transmit, byrow, dimnames) } \arguments{ \item{mdata.transmit}{specifies the elements of the matrix to be created. Fully diff --git a/man/mergeDS.Rd b/man/mergeDS.Rd index 4a996afd..535e243b 100644 --- a/man/mergeDS.Rd +++ b/man/mergeDS.Rd @@ -4,8 +4,18 @@ \alias{mergeDS} \title{mergeDS (assign function) called by ds.merge} \usage{ -mergeDS(x.name, y.name, by.x.names.transmit, by.y.names.transmit, all.x, - all.y, sort, suffixes.transmit, no.dups, incomparables) +mergeDS( + x.name, + y.name, + by.x.names.transmit, + by.y.names.transmit, + all.x, + all.y, + sort, + suffixes.transmit, + no.dups, + incomparables +) } \arguments{ \item{x.name, }{the name of the first data.frame to be merged specified in diff --git a/man/reShapeDS.Rd b/man/reShapeDS.Rd index 8da94e87..0a9bc250 100644 --- a/man/reShapeDS.Rd +++ b/man/reShapeDS.Rd @@ -4,8 +4,16 @@ \alias{reShapeDS} \title{reShapeDS (assign function) called by ds.reShape} \usage{ -reShapeDS(data.name, varying.transmit, v.names.transmit, timevar.name, - idvar.name, drop.transmit, direction, sep) +reShapeDS( + data.name, + varying.transmit, + v.names.transmit, + timevar.name, + idvar.name, + drop.transmit, + direction, + sep +) } \arguments{ \item{data.name, }{the name of the data.frame to be reshaped. Specified diff --git a/man/recodeValuesDS1.Rd b/man/recodeValuesDS1.Rd index 5068abc3..cabe4255 100644 --- a/man/recodeValuesDS1.Rd +++ b/man/recodeValuesDS1.Rd @@ -4,8 +4,11 @@ \alias{recodeValuesDS1} \title{recodeValuesDS1 an aggregate function called by ds.recodeValues} \usage{ -recodeValuesDS1(var.name.text = NULL, values2replace.text = NULL, - new.values.text = NULL) +recodeValuesDS1( + var.name.text = NULL, + values2replace.text = NULL, + new.values.text = NULL +) } \arguments{ \item{var.name.text}{a character string providing the name for the vector representing the diff --git a/man/recodeValuesDS2.Rd b/man/recodeValuesDS2.Rd index dbd20088..3828826d 100644 --- a/man/recodeValuesDS2.Rd +++ b/man/recodeValuesDS2.Rd @@ -4,9 +4,14 @@ \alias{recodeValuesDS2} \title{recodeValuesDS2 an assign function called by ds.recodeValues} \usage{ -recodeValuesDS2(var.name.text = NULL, values2replace.text = NULL, - new.values.text = NULL, numeric.output.format.possible, - force.output.format = "no", v2r.numeric = NULL) +recodeValuesDS2( + var.name.text = NULL, + values2replace.text = NULL, + new.values.text = NULL, + numeric.output.format.possible, + force.output.format = "no", + v2r.numeric = NULL +) } \arguments{ \item{var.name.text}{a character string providing the name for the vector representing the diff --git a/man/seqDS.Rd b/man/seqDS.Rd index 64a6caaf..563cd4aa 100644 --- a/man/seqDS.Rd +++ b/man/seqDS.Rd @@ -4,8 +4,13 @@ \alias{seqDS} \title{seqDS a serverside assign function called by ds.seq} \usage{ -seqDS(FROM.value.char, TO.value.char, BY.value.char, LENGTH.OUT.value.char, - ALONG.WITH.name) +seqDS( + FROM.value.char, + TO.value.char, + BY.value.char, + LENGTH.OUT.value.char, + ALONG.WITH.name +) } \arguments{ \item{FROM.value.char}{the starting value for the sequence expressed as an integer diff --git a/man/subsetDS.Rd b/man/subsetDS.Rd index 723df347..f25696af 100644 --- a/man/subsetDS.Rd +++ b/man/subsetDS.Rd @@ -4,8 +4,15 @@ \alias{subsetDS} \title{Generates a valid subset of a table or a vector} \usage{ -subsetDS(dt = NULL, complt = NULL, rs = NULL, cs = NULL, - lg = NULL, th = NULL, varname = NULL) +subsetDS( + dt = NULL, + complt = NULL, + rs = NULL, + cs = NULL, + lg = NULL, + th = NULL, + varname = NULL +) } \arguments{ \item{dt}{a string character, the name of the dataframe or the factor vector and the range of the subset.}