Bug 17220 - Optional ranges in chartr
Summary: Optional ranges in chartr
Alias: None
Product: R
Classification: Unclassified
Component: Wishlist (show other bugs)
Version: R 3.3.*
Hardware: All All
: P5 enhancement
Assignee: R-core
Depends on:
Reported: 2017-02-07 20:46 UTC by Marek Szatkowski
Modified: 2017-02-07 20:46 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Marek Szatkowski 2017-02-07 20:46:16 UTC
Currently chartr forces character ranges. As I understand from src/main/character.c there is no way to escape this.

This behavior require workarounds if '-' is the char to translate:

    chartr("abc-;","12345",";-cba") # this won't work, here with error but could fail silently!
    # but if `-` is on the beginning or end:
    chartr("abc;-","12354",";-cba") # works
    chartr("-abc;","41235",";-cba") # works

Please consider possibility of disabling ranges in chartr (additional argument to chartr or by allowing escaping `-` or other way).

Note: before I checked sources I ask about it on http://stackoverflow.com/questions/42013203/how-to-chartr-a-or-escaping-ranges