# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#' Check if column names start with patterns
#'
#' @description
#' This helper function takes two character vectors `mainstrs` and `patterns`, returning a boolean indicating
#' whether each element of `patterns` is a string pattern in which at least one element of `mainstrs` starts with.
#' In other words, for each element of `patterns`, does any element of `mainstrs` start with this particular pattern?
#' If so, return `TRUE`. This helper can be used to efficiently verify the argument `patterns` in `split_df()`,
#' especially when there is a large number of patterns.
#'
#' @param mainstrs A character vector of strings that are checked against each element in `patterns`.
#' @param patterns A character vector of pattern strings.
#'
#' @return A logical vector with the same length as `patterns`, indicating whether each pattern is one that
#' at least one string in `mainstrs` starts with.
#'
#' @export
#'
#' @examples
#' \donttest{
#' # Vector of patterns
#' patterns <- c("prefix_1", "predix_2", ...)
#'
#' # Checking if these patterns are valid for 'df'
#' check_patterns(mainstrs = names(df), patterns) |> all()
#'
#' # Find all invalid patterns
#' valid_index <- check_patterns(mainstrs = names(df), patterns)
#' patterns[!valid_index]
#' }
check_patterns <- function(mainstrs, patterns) {
.Call(`_surveyr_check_patterns`, mainstrs, patterns)
}
#' Print tables iteratively
#'
#' @description
#' This function takes a list of `flextable` objects and prints the raw code. \strong{Note} that chunk option
#' results must be set to \strong{asis}, i.e., `results='asis'`.
#'
#' @param l A list of `flextable` objects, which are s3 lists with certain structures.
#'
#' @return Invisible.
#'
#' @importFrom flextable flextable_to_rmd
#' @importFrom flextable autofit
#' @export
#'
#' @examples
#' \donttest{
#' # Toplines
#' print_tbls(list_toplines)
#'
#' # Crosstabs
#' print_tbls(list_xtabs)
#' }
print_tbls <- function(l) {
invisible(.Call(`_surveyr_print_tbls`, l))
}
#' Sum of Vector Elements (C++)
#'
#' @description
#' This function uses the `accu()` function from the `Armadillo` library, a C++ library for linear algebra and
#' scientific computing. For \strong{double-Precision} vectors, the run time of this function is faster than the base
#' `sum()` function, making it better suited for summing the `weight` variable with > 3000 elements.
#'
#' @param x A numeric vector.
#'
#' @return A numeric vector.
#'
#' @export
#'
#' @examples
#' \donttest{
#' # Summing a double vector
#' x <- runif(1000000, 0.0000001, 1.99999999)
#' sumcpp(x)
#' }
sumcpp <- function(x) {
.Call(`_surveyr_sumcpp`, x)
}
#' Remove leading and trailing spaces of strings in a vector (C++)
#'
#' @description
#' This function removes all leading or trailing white space, including
#' space (' '), form feed (`\f`), line feed (`\n`), carriage return (`\r'`,
#' horizontal tab (`\t`), and vertical tab (`\v`), from a character vector.
#'
#' @param s A character vector.
#'
#' @return A character vector.
#'
#' @export
#'
#' @examples
#' \donttest{
#' x <- c(" leading", "trailing ", " both ")
#' trimcpp(x)
#' }
trimcpp <- function(s) {
.Call(`_surveyr_trimcpp`, s)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.