charmatch_loop: Iterative partial string matching with updates.

Description Usage Arguments Value

View source: R/charmatch_loop.R

Description

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.

Usage

1

Arguments

x

The character string that we would like to update.

table

The character string containing the information to be used when updating x.

Value

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:

x

The original x-argument as given to the function.

table

The original table-argument as given to the function.

status

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

problems

A logical value that is TRUE if any ambiguous components where detected

ambiguous

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.

ambiguous_info

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.


LAJordanger/leanRcoding documentation built on Feb. 27, 2020, 4:42 p.m.