0

I just realized that there were loads of really useful mathematic symbols when you hold down the Option key on my MacBook.

≤ ≥ ≠ ÷ • « ∑ √

It’s like a wonderland of mathematical symbols and I would love to map these to different functions in R, for wonderous coding.

Edit - I should clarify, I don’t want to set them as variable names, I was hoping to use them in functions. For example ∑ is the mathematical symbol for sum, so:

∑() <- base::sum()

Or square root

√() <- base::sqrt()

Only problem, of course, is that R doesn’t recognize them.

Unexpected Input

I generally program in the Terminal too. Is there any way to force R to recognize special characters?

Chris
  • 59
  • 5
  • 1
    Backticks around the text - ` like \`÷\` - but I agree with the below comment that this is a bad idea – thelatemail Jan 03 '19 at 22:30
  • 4
    You should not do that, even if it's possible. You open up the possibility of encoding issues, not to mention one of the fundamental rules of programming is to give things useful names. Calling something `∑` tells you nothing – Mako212 Jan 03 '19 at 22:30
  • 2
    What exactly are you typing into the terminal? The R parser has rules about what van be used as a valid variable or function name. You cannot change those rules. – MrFlick Jan 03 '19 at 22:31
  • No, I wasn’t planning on naming variables with those characters, I was thinking fo mapping them to functions for example ∑() <- base::sum(), ∑ being the mathematical symbol for sum. Maybe if R won’t do it, there’a way to have the terminal translate it before R processes it. – Chris Jan 04 '19 at 03:27
  • https://stackoverflow.com/questions/28483441/how-does-r-handle-unicode-utf-8 – Ben Bolker Jan 04 '19 at 04:15

0 Answers0