gsubfn: Utilities for Strings and for Function Arguments

msra

Cited 23|Views4
No score
Abstract
gsubfn is an R package used for string matching, substitution and parsing. A seemingly small generalization of gsub, namely allow the replacement string to be a replacement function, formula or proto object, can result in signicantly increased power and applicability. The resulting function, gsubfn is the namesake of this package. Built on top of gsubfn is strapply which is similar to gsubfn except that it returns the output of the function rather than substituting it back into the source string. In the case of a replacement formula the formula is interpreted as a function as explained in the text. In the case of a replacement proto object the object space is used to store persistant data to be communicated from one function invocation to the next as well as to store the replacement function/method itself. The ability to have formula arguments that represent functions can be used not only in the functions of the gsubfn package but can also be used with any R function without modifying its source. Just preface any R function with fn$ and subject to certain rules which are intended to distinguish which formulas are intended to be functions and which are not, the formula arguments will be translated to functions, e.g. fn$integrate(~ x^2/, 0, 1). This facility has widespread applicability right across R and its packages. match.funfn, is provided to allow developers to readily build this functionality into their own functions so that even the fn$ prex need not be used.
More
Translated text
Key words
gsub,r.,strings
AI Read Science
Must-Reading Tree
Example
Generate MRT to find the research sequence of this paper
Chat Paper
Summary is being generated by the instructions you defined