-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathc14_date_list_fuse.R
52 lines (46 loc) · 1.15 KB
/
c14_date_list_fuse.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#### fuse ####
#' @name fuse
#' @title Fuse multiple \strong{c14_date_list}s
#'
#' @description This function combines \strong{c14_date_list}s with
#' \code{dplyr::bind_rows()}. \cr
#' This is not a joining operation and it therefore
#' might introduce duplicates. See \code{c14bazAAR::mark_duplicates()}
#' and \code{c14bazAAR::remove_duplicates()} for a way to find and remove
#' them.
#'
#' @param ... objects of class c14_date_list
#'
#' @return an object of class c14_date_list
#' @export
#'
#' @examples
#' # fuse three identical example c14_date_lists
#' fuse(example_c14_date_list, example_c14_date_list, example_c14_date_list)
#'
#' @rdname fuse
#'
fuse <- function(...) {
UseMethod("fuse")
}
#' @rdname fuse
#' @export
fuse.default <- function(...) {
stop("x is not an object of class c14_date_list")
}
#' @rdname fuse
#' @export
fuse.c14_date_list <- function(...) {
# check class of input objects
issesnu <- list(...) %>%
sapply(FUN = is.c14_date_list) %>%
all %>%
`!`
if(issesnu) {
stop("One of the input objects is not of class c14_date_list.")
}
# actual bind
dplyr::bind_rows(...) %>%
as.c14_date_list() %>%
return()
}