# Generated by fusen: do not edit by hand
#' Filter Target Dataframe for Block Sizes
#'
#' Description
#'
#' @param .block
#' A block as character string (names of ls element from split_block())
#' @param .tab
#' Target table (tt element from split_block())
#' @param .size
#' Second element of .char_block (3. Argument of split_block())
#' @return
#' A Dataframe
#'
#' @noRd
#' @examples
#' tab_source <- table_source[1:100, ]
#' tab_target <- table_target[1:999, ]
#' cols_match <- c("name", "iso3", "city", "address")
#' char_block = c(25, 5)
#'
#' lblock <- split_block(
#' .source = tab_source,
#' .target = tab_target,
#' .cols_match = cols_match,
#' .char_block = char_block
#' )
#'
#' filter_block(
#' .block = names(lblock$ls)[1],
#' .tab = lblock$tt,
#' .size = char_block[2]
#' )
filter_block <- function(.block, .tab, .size) {
n__ <- NULL
int_ <- as.integer(unlist(stringi::stri_split_fixed(.block, "-")))
min_ <- int_[1] - .size
max_ <- int_[2] + .size
if (is.infinite(.size)) {
return(.tab)
} else {
return(dplyr::filter(.tab, n__ %in% min_:max_))
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.