Skip to content

Commit

Permalink
bug fixes in export of results in dfl_decompose
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgallusser committed Jan 26, 2024
1 parent 8411ce6 commit b79585a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions R/dfl_decompose.R
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ dfl_decompose <- function(formula,
stop("The arguments 'dep_var' and 'weights' in 'custom_statistic_function' must be defined!")
}
}
if(length(statistics)==0){
if(length(statistics)==0 & is.null(custom_statistic_function)){
estimate_statistics <- FALSE
}

Expand Down Expand Up @@ -996,7 +996,7 @@ dfl_decompose_estimate <- function(formula,
# Save quantiles and other statistics in different objects -------------------

if("quantiles" %in% statistics){
if(length(probs) == 1){
if(length(probs) == 1 & length(statistics) == 1){
decomposition_quantiles <- as.data.frame(matrix(c(probs, Delta[, 1]), nrow = 1))
names(decomposition_quantiles) <- c("probs", rownames(Delta))
rownames(decomposition_quantiles) <- paste0(probs * 100, "%-quantile")
Expand All @@ -1012,7 +1012,13 @@ dfl_decompose_estimate <- function(formula,
if("quantiles" %in% statistics & length(statistics) > 1){
decomposition_other_statistics <- Delta[(length(probs)+1):nrow(Delta), ]
}else if("quantiles" %in% statistics == FALSE){
decomposition_other_statistics <- Delta
if(length(statistics) == 1 | !is.null(custom_statistic_function)){
decomposition_other_statistics <- as.data.frame(matrix(Delta[, 1], nrow = 1))
names(decomposition_other_statistics) <- rownames(Delta)
rownames(decomposition_other_statistics) <- ifelse(is.null(statistics), "Custom statistic", statistics)
}else{
decomposition_other_statistics <- Delta
}
}else{
decomposition_other_statistics <- NULL
}
Expand Down

0 comments on commit b79585a

Please sign in to comment.