-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
900e463
commit a0c26cf
Showing
5 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#' Join Null Data | ||
#' | ||
#' This function joins two data frames, `summary_data` and `calculated_data`, | ||
#' using a full join if `summary_data` is not NULL. If `summary_data` is NULL, | ||
#' it assigns `calculated_data` to `summary_data`. | ||
#' | ||
#' @param summary_data A data frame representing summary data. | ||
#' @param calculated_data A data frame containing calculated data. | ||
#' | ||
#' @return A data frame resulting from the full join of `summary_data` and `calculated_data`, | ||
#' or `calculated_data` if `summary_data` is NULL. | ||
#' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' # summary_data is NULL | ||
#' summary_data <- NULL | ||
#' calculated_data <- data.frame(x = 1:5, y = letters[1:5]) | ||
#' join_null_data(summary_data, calculated_data) | ||
#' | ||
#' # summary_data is not NULL | ||
#' summary_data <- data.frame(x = 1:3, y = letters[1:3]) | ||
#' calculated_data <- data.frame(x = 4:5, y = letters[4:5]) | ||
#' join_null_data(summary_data, calculated_data) | ||
join_null_data <- function(summary_data, calculated_data){ | ||
if (is.null(summary_data)){ | ||
summary_data <- calculated_data | ||
} else{ | ||
summary_data <- dplyr::full_join(summary_data, calculated_data) | ||
} | ||
return(summary_data) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.