read_exponential {genscore} | R Documentation |
Parses the integer coefficient in an exponential term.
Description
Parses the integer coefficient in an exponential term.
Usage
read_exponential(s, has_index)
Arguments
s |
A string that starts with one of the following forms: |
has_index |
A logical, indicates whether the term is written in a component (e.g. |
Details
Parses the coefficient in the first exponential term and returns the rest of the terms.
Value
A list containing the following elements:
power_numer |
An integer, the integer coefficient inside the first exponential term. |
idx |
An integer, the index of the term matched (e.g. |
s |
A string, the rest of the unparsed string. |
If parsing is unsuccessful, NULL
is returned.
Examples
# Unsuccessful parsing, not starting with exponential, returns \code{NULL}.
read_exponential("x", FALSE)
# Unsuccessful parsing, not starting with exponential, returns \code{NULL}.
read_exponential("x1^2+exp(2x2)", TRUE)
read_exponential("exp(x)", FALSE)
read_exponential("exp(x1)", TRUE)
read_exponential("exp(-x)", FALSE)
read_exponential("exp(-x1)+x2^2", TRUE)
read_exponential("exp(2x)", FALSE)
read_exponential("exp(2x1)+x2^(-2/3)", TRUE)
read_exponential("exp(-2x)", FALSE)
read_exponential("exp(-2x1)+exp(x3)", TRUE)
read_exponential("exp(12x)", FALSE)
read_exponential("exp(12x2)+x3^(-3)+x4^2", TRUE)
read_exponential("exp(-12x)", FALSE)
read_exponential("exp(-12x3)+x1^(2/5)+log(x2)", TRUE)
read_exponential("exp(123*x)", FALSE)
read_exponential("exp(123*x1)+x2^4", TRUE)
read_exponential("exp(-123*x)", FALSE)
read_exponential("exp(-123*x4)+exp(2*x3)", TRUE)