fstrcapture {ympes}R Documentation

Capture string tokens into a data frame

Description

fstrcapture() is a replacement for strcapture() with better performance when perl = TRUE.

Usage

fstrcapture(pattern, x, proto, perl = TRUE, useBytes = FALSE)

Arguments

pattern

The regular expression with the capture expressions.

x

A character vector in which to capture the tokens.

proto

A data.frame or S4 object that behaves like one. See details.

perl

Should Perl-compatible regexps be used?

useBytes

If TRUE the matching is done byte-by-byte rather than character-by-character.

Value

A tabular data structure of the same type as proto, so typically a data.frame, containing a column for each capture expression. The column types and names are inherited from proto. Cases in x that do not match pattern have NA in every column.

Note

Compared to strcapture(), fstrcapture() sets the default value for perl to TRUE. Apart from this it can be used as a drop-in replacement.

See Also

strcapture() for further details.

Examples


x <- "chr1:1-1000"
pattern <- "(.*?):([[:digit:]]+)-([[:digit:]]+)"
proto <- data.frame(chr=character(), start=integer(), end=integer())
fstrcapture(pattern, x, proto)


[Package ympes version 1.1.0 Index]