Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions R/g3_fit_combine.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,18 @@ bind_fit_components <- function(fit_list, component){
return(out)

}

#' this is a possible generalisation to bind all the elements of multiple gadget.fit objects
bind_fit <- function(fit_list, ...){
# initialise an empty list
out <- fit_list[[1]]
out[] <- NA
for(i in 1:length(out)){
if(sum(class(fit_list[[1]][[names(out)[i]]]) == "data.frame") == 1){
tmp <- sapply(fit_list,function(x){x[names(out)[i]]})
names(tmp) <- names(fit_list) # replace with readable model names
out[[i]] <- bind_rows(tmp, .id="id")
} else { NULL }}

return(out)
}
Loading