Learn R Programming

mathgraph (version 0.9-14)

.find.I.of: Find limits of I() in a String

Description

Returns either NULL or a two-column matrix where each row gives the first and last character of a call to I.

Usage

.find.I.of(string, nesting.ok = FALSE)

Arguments

string

a single character string.

nesting.ok

logical value: if TRUE, then all occurrences are given. If FALSE, then calls to I within other calls to it are ignored.

Value

a numeric matrix with two columns, or NULL. Each row represents one call to I. The first column is the number of the character within the string that starts the call (i.e., the "I"). The second column is the number of the character within the string that ends the call (the ")").

BUGS

Parentheses inside quotes in the call to I will confuse it.

One or more spaces after the "I" will cause the call to be unrecognized. However, if the string is parsed and then deparsed, the space will go away.

References

S Poetry, Patrick J. Burns, Section 11.2, p. 280

See Also

build.mathgraph

Examples

Run this code
# NOT RUN {
.find.I.of("~ x + I(x^2)")
.find.I.of("~ x + I(x^2 + I(y^3))")
# }
# NOT RUN {
.find.I.of("~ x + I(x^2 + I(y^3))", TRUE)
# }

Run the code above in your browser using DataLab