I want to use unicode superscript and subscripts for variable names for my math homework as it's easier to relate the variables to math, like σ² for variance, μ₁, μ₂ for means and so on. Also because they look nicer (than let's say μ_1 or μ1).
So I can make unicode variables in R, like
μ = 2
works fine, but unicode superscript and subscript doesn't work, something like.
μ₂ = 3
will give me an error:
> μ₂ = 3
Error: unexpected input in "μ₂"
Output of make.names
gives me:
> make.names("μ₂")
[1] "μ."
Which is similar to how special symbols like + - are replaced in make.names, so I thought maybe ² or ₂ have special meanings, but they don't seem to.
> ²
Error: unexpected input in "²"
Here are some related questions about unicode, but they aren't exactly what I want
My files are saved as utf-8, and Sys.getenv()
gives me LANG en_US.UTF-8
and even if I do Sys.setlocale("LC_ALL", 'en_US.UTF-8')
(from another question), it doesn't change anything.