[R] Python difflib R equivalent?
Spencer Graves
spencer.graves at prodsyse.com
Thu Jul 28 18:39:19 CEST 2011
There is a package "rJython", which claims to provide an "R interface to
Python via Jython". I haven't used it, but the lead author, Gabor
Grothendieck, is well known in the R community. Spencer
On 7/28/2011 9:15 AM, Prof Brian Ripley wrote:
> On Thu, 28 Jul 2011, Bert Gunter wrote:
>
>> Paul:
>>
>> 1. I do not know if any such library exists.
>
> Not to my knowledge, and we have contemplated providing such
> functions. But for files see e.g. tools::Rdiff, and generally R will
> not be a good way to do this sort of thing on files (since the
> flexibility of R's i/o via connections does have a cost)
>
>> 2. However, if I understand correctly, one usually does this sort of
>> thing in R with functions like ?match (or ?"%in%") and logical
>> comparison operations like ?"==" . Of course, for numeric
>> comparisons, you need to be aware of R FAQ 7.31
>>
>> If you are interested in comparing what in R are character vectors,
>> then various string operators, e.g. ?grep, ?regexp and character
>> operation packages (e.g. gsubfn, stringr) may be of use.
>>
>> As usual, you are more likely to receive a helpful answer if you do as
>> the posting guide requests and provide a small, reproducible example
>> of the sort(s) of thing(s) you want to do.
>
> Or at least a URI of examples you wish to emulate, which for difflib
> seem to be the sort of thing POSIX diff and friends are used for.
>
>> Cheers,
>> Bert
>>
>> On Thu, Jul 28, 2011 at 4:05 AM, Paul <newzealandspaul at gmail.com> wrote:
>>> Hi,
>>>
>>> Does anyone know of a R library that is equivalent in functionality to
>>> the Python standard libraries' difflib library? The python docs say
>>> this about difflib:
>>>
>>> "This module provides classes and functions for comparing sequences.
>>> It can be used for example, for comparing files, and can produce
>>> difference information in various formats, including HTML and context
>>> and unified diffs."
>>>
>>> http://docs.python.org/library/difflib.html
>>>
>>> Thanks,
>>>
>>> Paul
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> 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.
>>>
>>
>>
>>
>> --
>> "Men by nature long to get on to the ultimate truths, and will often
>> be impatient with elementary studies or fight shy of them. If it were
>> possible to reach the ultimate truths without the elementary studies
>> usually prefixed to them, these would not be preparatory studies but
>> superfluous diversions."
>>
>> -- Maimonides (1135-1204)
>>
>> Bert Gunter
>> Genentech Nonclinical Biostatistics
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> 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.
>>
>
--
Spencer Graves, PE, PhD
President and Chief Technology Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph: 408-655-4567
web: www.structuremonitoring.com
More information about the R-help
mailing list