Description Usage Arguments Value
View source: R/charmatch_loop.R
This function builds on charmatch
, but with the twist that
it updates the first vector x
based on the information found
in the second vector table
. A while
-construction is
used in the updating procedure, in order to successively reduce the
length of the the two vectors by ignoring parts that already was
matched. Note that this function only accept character-vectors as
input, and that it will get rid of duplicated entries from the
table
-argument. This function was originally created as a
helper for the functions update_call
and
update_formals
, but it might be of interest for other too
since the result contains some attributes that can be handy to use
in tests that compare the content of x
against table
.
1 | charmatch_loop(x, table)
|
x |
The character string that we would like to update. |
table |
The character string containing the information to be
used when updating |
A revised version of x
will be returned, in which
the components might have been attempted updated against the
content of table
. The result will contain any
attributes x
already had, and it will moreover receive a
new attribute charmatch_loop
, which will be a list
containing the following items:
The original x
-argument as given to the function.
The original table
-argument as given to the
function.
A vector that encodes the different components of the
result. -1
is used to mark a component of x
that
did not occur in table
; 0
is used to mark
ambiguous components where several possible matches still are
present in table
; 1
represents components where
unique match were obtained
A logical value that is TRUE
if any
ambiguous components where detected
A list that specifies the whose names are the
ambiguous components from the result, and whose content will be
the components from table
that makes it ambiguous.
Note: This part is only included if ambiguous components are
detected.
The same information as in ambiguous
,
but presented as a vector with one character-string for each
ambiguous component. This simplifies the creation of an
error-message in functions that requires that no ambiguous
components remains, like e.g. update_call
and
update_formals
. Note: This part is only included if
ambiguous components are detected.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.