#StackBounty: #r #character-encoding R friendly greek characters

Bounty: 50

I noticed that I can use some Greek letters as names while others will be either illegal or just aliases to letters from the latin alphabet.

Basically I can use β or µ (though β is changed to ß when printing and ß and β act as alliases)

list(β = 1)
# $ß
# [1] 1
list(μ = 1)
# $µ
# [1] 1

α, Γ, δ, ε, Θ, π, Σ, σ, τ, Φ, φ and Ω are allowed but act as alliases to latin letters.

list(α = 1)
# $a
# [1] 1

αa <- 42
# [1] 42

GG <- 33
# [1] 33

Other letters I’ve tested just don’t “work”:

ι <- 1
# Error: unexpected input in ""
Λ <- 1
# Error: unexpected input in ""
λ <- 1
#Error: unexpected input in ""

I was surprised about λ as it’s defined by the package wrapr‘s define_lambda, so I assume this depends on the system.

I know similar or identical looking characters can have different encodings, and some of them don’t go well with copy/paste between apps, the code of this question returns the described output when pasted back to RStudio.

?make.names says :

underline characters and starts with a letter or the dot not followed
by a number

So part of the question is : what’s a letter ? and what’s going on here ?

More specifically:

  • Are there greek characters that will safely work on all R installations, in particular, are µ and β (or ß) safe to use in a package.
  • why isn’t λ ( intToUtf8(955) ) usable on my system while it seems to be commonly use by wrapr‘s users.
  • Are there other non latin letters, greek or not, that I could safely use in my code ? (for instance Norwegian ø looks cool and seems to work on my system)

This all was prompted by the fact I’m looking for a one (or 2) character function name that wouldn’t conflict with an existing or commonly used name, and would look a bit funky. . is already used a lot and I use .. already as well.

from sessionInfo() :

R version 3.5.2 (2018-12-20)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252  

Get this bounty!!!

Leave a Reply
