computeChar_index: Locate position of first occurence of a pattern

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/xpssComputeStrings.R

Description

Helper Function for xpssCompute. R Implementation of the SPSS CHAR.INDEX Function.

Usage

1
computeChar_index (x,pattern = NULL, split = 0)

Arguments

x

atomic character or character vector.

pattern

atomic character to look for.

split

atomic numeric. Number of parts pattern to divide to.

Details

computeChar_index(x="Hello user", pattern="user") Returns a number indicating the character position of the first occurrence of the first letter of 'user' in 'Hello user'. The optional third argument, split, is a number, which must be a positive integer used to divide 'user' into separate strings. The split value must be able to divide the pattern string without remainder.

Value

Numeric. Position of the first occurence of the pattern.

Author(s)

Bastian Wiessner

See Also

str_locate_all

Examples

1
2
3
4
5
6
xpssCompute(x="there is no letter in word", fun="computeChar_index", pattern="letter")

xpssCompute(x="there is no letter in word", fun="computeChar_index", pattern="string")

xpssCompute(x=c("fruits are sweet", "fruits are sour","fruits are salty"),
fun="computeChar_index", pattern="sweet")

translateSPSS2R documentation built on May 30, 2017, 4:31 a.m.