Skip to content

Commit a7a252f

Browse files
authored
Merge pull request #41 from vbartolino/patch-1
Update g3_fit_combine.R
2 parents 798d644 + 9e0fc61 commit a7a252f

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

R/g3_fit_combine.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,18 @@ bind_fit_components <- function(fit_list, component){
2323
return(out)
2424

2525
}
26+
27+
#' this is a possible generalisation to bind all the elements of multiple gadget.fit objects
28+
bind_fit <- function(fit_list, ...){
29+
# initialise an empty list
30+
out <- fit_list[[1]]
31+
out[] <- NA
32+
for(i in 1:length(out)){
33+
if(sum(class(fit_list[[1]][[names(out)[i]]]) == "data.frame") == 1){
34+
tmp <- sapply(fit_list,function(x){x[names(out)[i]]})
35+
names(tmp) <- names(fit_list) # replace with readable model names
36+
out[[i]] <- bind_rows(tmp, .id="id")
37+
} else { NULL }}
38+
39+
return(out)
40+
}

0 commit comments

Comments
 (0)