hl_diff {emphatic} | R Documentation |
Colour the differences between character representations of objects
Description
Highlight the differences between two strings in
terms of substitutions, insertions and deletions calculated by
the generalized Levenshtein (edit) distance (using adist()
)
Usage
hl_diff(
x,
y,
coerce = "default",
fill = NULL,
text = NULL,
opts = hl_opts(),
sep = NULL,
...
)
Arguments
x , y |
each argument is a single string. vectors of strings not currently supported. |
coerce |
How should non-character arguments be coerced to character strings?
|
fill |
named list of colours for substitutions, insertions and deletions with names 'sub', 'ins' and 'del'. If set to NULL (the default) then default colours will be used. |
text |
named list of colours for the text for 'sub', 'ins' and 'del'
operations. If |
opts |
create options list |
sep |
character string of the line separating the two objects. Default: |
... |
further arguments passed to |
Details
This works character-by-character, so the displayed difference for multiline strings can be quite busy if there are a lot of changes.
Value
list of 'emphatic' objects which could be rendered to ANSI (for example)
Examples
hl_diff('hello', 'there')