Skip to content

Commit

Permalink
Fix handling of summary statistics in combined 'mtable' results
Browse files Browse the repository at this point in the history
  • Loading branch information
melff committed Nov 1, 2018
1 parent ddbf1f1 commit 70d0145
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/R/mtable-manip.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ combine_mtables <- function(...){
parameter.names <- unique(unlist(parameter.names))

summary.stats <- lapply(args,get.summary.stats)
summary.stats <- unique(unlist(summary.stats))
summary.stats <- unlist(summary.stats,recursive=FALSE)

signif.symbols <- attr(args[[1]],"signif.symbols")
factor.style <- attr(args[[1]],"factor.style")
Expand Down
11 changes: 7 additions & 4 deletions pkg/R/mtable.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ selectSummaryStats <- function(x,n) {
else if(isTRUE(n)){
cls <- class(x)
sumstats.name <- paste0("summary.stats.",cls)
sumstats <- getOption(sumstats.name)

if(!length(sumstats))
sumstats <- lapply(sumstats.name,getOption)
if(length(sumstats)){
sumstats <- unlist(sumstats)
sumstats[1]
}
else
sumstats <- getOption("summary.stats.default")
sumstats
}
Expand Down Expand Up @@ -402,7 +405,7 @@ relabel.memisc_mtable <- function(x,...,gsub=FALSE,fixed=!gsub,warn=FALSE){

pt_getrow <- function(x,i){
y <- x[i,]
yisn <- sapply(y,is.null)
isn <- sapply(y,is.null)
if(any(isn)) return(y[!isn])
else return(y)
}
Expand Down

0 comments on commit 70d0145

Please sign in to comment.