Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
TuomasBorman committed Mar 7, 2024
1 parent f291a54 commit cfcb016
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,23 @@
# data.frame
#' @importFrom dplyr full_join
.full_join_list <- function(res){
df <- Reduce(function(df1, df2){
# Get common columns
common_cols <- intersect(colnames(df1), colnames(df2))
# Merge based on common columns
temp <- full_join(df1, df2, by = common_cols)
return(temp)
}, res)
# Remove empty elements
res <- res[ lengths(res) > 0 ]

Check warning on line 394 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L394

Added line #L394 was not covered by tests
# If there is more than one element, merge them
if( length(res) > 1 ){
df <- Reduce(function(df1, df2){

Check warning on line 397 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L396-L397

Added lines #L396 - L397 were not covered by tests
# Get common columns
common_cols <- intersect(colnames(df1), colnames(df2))

Check warning on line 399 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L399

Added line #L399 was not covered by tests
# Merge based on common columns
temp <- full_join(df1, df2, by = common_cols)
return(temp)
}, res)
} else if( length(res) == 1 ){

Check warning on line 404 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L401-L404

Added lines #L401 - L404 were not covered by tests
# Otherwise if there is only one element, give the element
df <- res[[1]]

Check warning on line 406 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L406

Added line #L406 was not covered by tests
} else{
# If all the data.frames were without information, give NULL
df <- NULL

Check warning on line 409 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L409

Added line #L409 was not covered by tests
}
return(df)
}

0 comments on commit cfcb016

Please sign in to comment.