Learn R Programming

spatstat.linnet (version 3.2-2)

begins: Check Start of Character String

Description

Checks whether a character string begins with a particular prefix.

Usage

begins(x, firstbit)

Value

Logical vector of the same length as x.

Arguments

x

Character string, or vector of character strings, to be tested.

firstbit

A single character string.

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au

Rolf Turner rolfturner@posteo.net

and Ege Rubak rubak@math.aau.dk

Details

This simple wrapper function checks whether (each entry in) x begins with the string firstbit, and returns a logical value or logical vector with one entry for each entry of x. This function is useful mainly for reducing complexity in model formulae.

Examples

Run this code
  begins(c("Hello", "Goodbye"), "Hell")
  begins("anything", "")

Run the code above in your browser using DataLab