indexof: Find index of needle in haystack

View source: R/custom_func.R

indexofR Documentation

Find index of needle in haystack

Description

Find index of value in vector or string. Equivalent of .IndexOf() in Insight Maker.

Usage

indexof(haystack, needle)

Arguments

haystack

Vector or string to search through

needle

Value to search for

Value

Index, integer

Examples

indexof(c("a", "b", "c"), "b") # 2
indexof("haystack", "hay") # 1
indexof("haystack", "m") # 0

sdbuildR documentation built on Nov. 19, 2025, 5:07 p.m.