Learn R Programming

sdbuildR (version 2.0.0)

indexof: Find index of value in vector or string

Description

Equivalent of .IndexOf() in Insight Maker.

Usage

indexof(haystack, needle)

Value

Index, integer

Arguments

haystack

Vector or string to search through

needle

Value to search for

Examples

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

Run the code above in your browser using DataLab