get_nth_part: Extracts the first (or nth) entry from each split.

View source: R/utils.R

get_nth_partR Documentation

Extracts the first (or nth) entry from each split.

Description

Extracts the first (or nth) entry from each split.

Usage

get_nth_part(x, delimiter, entry_no)

Arguments

x

A character vector.

delimiter

A character to split by.

entry_no

A number indicating which part of split to return.

Value

A character vector containing parts

Examples

x <- c("2wk.1", "2wk.2", "2wk.3", "2wk.4", "2wk.5", "2wk.6", "2wk.7", "2wk.8", "2wk.9", "2wk.10")
# delimiter = "\." # double slashes are escape characters for special characters like "."
# entry_no = 1L
get_nth_part(x, "\\.", "\\.")
# The return value is c("2wk", "2wk", "2wk", "2wk", "2wk", "2wk", "2wk", "2wk", "2wk", "2wk", "2wk", "2wk")
get_nth_part(x, "wk", 1)

kazeera/hourglass documentation built on April 5, 2025, 7:18 a.m.