-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from datashield/v5.1-dev
V5.1 dev
- Loading branch information
Showing
39 changed files
with
573 additions
and
798 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
Oops, something went wrong.