find_missing_starts: Find start positions that cannot be found in ”data”

View source: R/find_missing_starts.R

find_missing_startsR Documentation

Find start positions that cannot be found in `data`

Description

\Sexpr[results=rd, stage=render]{lifecycle::badge("maturing")}

Tells you which values and (optionally) skip-to-numbers that are recursively removed when using the "l_starts" method with `remove_missing_starts` set to TRUE.

Usage

find_missing_starts(data, n, starts_col = NULL, return_skip_numbers = TRUE)

Arguments

data

data.frame or vector.

N.B. If `data` is a grouped data.frame, the function is applied group-wise and the output is a list of either vectors or lists. The names are based on the group indices (see dplyr::group_indices()).

n

List of starting positions.

Skip values by c(value, skip_to_number) where skip_to_number is the nth appearance of the value in the vector.

See group_factor() for explanations and examples of using the "l_starts" method.

starts_col

Name of column with values to match when `data` is a data.frame. Pass 'index' to use row names. (Character)

return_skip_numbers

Return skip-to-numbers along with values (Logical).

Value

List of start values and skip-to-numbers or a vector with the start values. Returns NULL if no values were found.

N.B. If `data` is a grouped data.frame, the function is applied group-wise and the output is a list of either vectors or lists. The names are based on the group indices (see dplyr::group_indices()).

Author(s)

Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk

See Also

Other l_starts tools: differs_from_previous(), find_starts(), group_factor(), group()

Examples

# Attach packages
library(groupdata2)

# Create a data frame
df <- data.frame(
  "a" = c("a", "a", "b", "b", "c", "c"),
  stringsAsFactors = FALSE
)

# Create list of starts
starts <- c("a", "e", "b", "d", "c")

# Find missing starts with skip_to numbers
find_missing_starts(df, starts, starts_col = "a")

# Find missing starts without skip_to numbers
find_missing_starts(df, starts,
  starts_col = "a",
  return_skip_numbers = FALSE
)

groupdata2 documentation built on July 9, 2023, 6:46 p.m.