Skip to content

Commit

Permalink
feat: output format for boundedMeanDP
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasopaum committed Mar 27, 2023
1 parent 55af228 commit 12414a1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions R/ds.boundedMeanDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ ds.boundedMeanDP <- function(input_data, epsilon, lower_bound, upper_bound, type

Nstudies <- length(datasources)
mean.mat <- matrix(as.numeric(unlist(mean.data)),nrow=Nstudies,byrow=TRUE)
mean.split <- mean.mat[,1]
mean.combine <- ((t(matrix(mean.mat[,2]))%*%mean.mat[,1])/sum(mean.mat[,2]))[[1]]

mean.split <- mean.mat
dimnames(mean.split) <- c(list(names(mean.data), names(mean.data[[1]])))

mean.combine <- t(matrix(mean.mat[1,]))
mean.combine[1,1] <- ((t(matrix(mean.mat[,2]))%*%mean.mat[,1])/sum(mean.mat[,2]))
mean.combine[1,2] <- sum(mean.mat[,2])
dimnames(mean.combine) <- c(list("studiesCombined"),list(names(mean.data[[1]])))

if (type=="combine") return(list(Global.Mean=mean.combine,Nstudies=Nstudies))
if (type=="split") return(list(Mean.by.Study=mean.split,Nstudies=Nstudies))
Expand Down

0 comments on commit 12414a1

Please sign in to comment.