[R] Diff'ing 2 strings
Bert Gunter
bgunter@4567 @ending from gm@il@com
Sat Jan 5 18:21:02 CET 2019
It's the "split" string not the "sep" string, as you and probably everyone
else already realizes.
And, of course, it could be a regular expression, not literally a character
string.
-- Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Sat, Jan 5, 2019 at 7:19 AM Bert Gunter <bgunter.4567 using gmail.com> wrote:
> I do not know what you mean in your string context, as diff in Linux finds
> lines in files that differ. A reproducible example -- posting guide! --
> would be most useful here.
>
> However, maybe something of the following strategy might be useful:
>
> 1. Break up your strings into lists of string "chunks" relevant for your
> context via strspit() . Using "" (empty character) as the "sep" string
> would break your strings into individual characters; "\n" would break it
> into "lines" separated by the return
> character; etc.
>
> 2. Compare your lists using e.g. lapply() and probably ?match and friends
> like ?setdiff
>
> You should also probably check out the stringr package to see if it
> contains what you need. Also, if this is gene sequence related, posting on
> the Bioconductor list rather than here is likely to be more fruitful.
>
> Cheers,
> Bert
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Sat, Jan 5, 2019 at 5:58 AM Sebastien Bihorel <
> sebastien.bihorel using cognigencorp.com> wrote:
>
>> Hi,
>>
>> Does R include an equivalent of the linux diff command?
>>
>> Ideally I would like to diff 2 fairly complex strings and extract the
>> differences without having to save them on disk and using a system('diff
>> file1 file2') command.
>>
>> Thanks
>>
>> Sebastien
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list