# Setting up Al's R session

Al wanted to use my computer to do some simple calculations, so I lent him the use of my R terminal for a bit. He complained though, saying it wasn't set up how he liked it. I said "No problem Al, set it up how you like and I'll just revert it later." This suited Al, and I left him to it. Al isn't a big fan of online R implementations like TIO, they don't seem to support his preferred way of coding.

After a few minutes, I came back and asked how it went. "everything fine", he said. I glanced at his session and it didn't look fine to me — only one of the four results looked correct! But Al knows R inside out, he must have been telling the truth.

Here is a transcript of Al's R session, as it appeared on the screen (Al uses RStudio 1.1.463 and R 3.6.3 if it matters, but I don't think it does here). The question is, how did Al "set up" his session to produce this output?

## what did Al type here?
‮32+55
[1] 87
‮14*21
[1] 294
‮91/7
[1] 13
‮12-21
[1] -9


rules:

• Al only typed one function call which is somewhere in the standard R libraries.
• the function didn't import any code or refer to any external files (no source, install.packages, library etc..).
• Al didn't type cat("55+23\n[1]......-9"), it is something that could reasonably be interpreted as "setting up an R session"

scoring:

• the primary scoring criterion is the number of bytes in the answer. Ties will be broken in ASCII-order, that is, if two valid answers are the same length the winner is the one which is first "alphabetically" (according to ASCII ordering).
• I think it belongs to puzzling.stackexchange.com rather than here, where whe are supposed to answer with code with a winning criterion? Sep 17 at 13:53
• Fair enough --- this works as a code-golf, so have changed to that. There are multiple possible answers, I think.
– JDL
Sep 17 at 14:03
• Before I spoil the answer to other people that know R, does what you have in mind work in TIO? I have tried something but it seems they disabled the support for this in TIO.. Sep 17 at 14:37
• @Kaddath my intended solution doesn't work in TIO, which disables many of the functions you might use to customise your R session. I will add that to the question, though so thanks for trying TIO!
– JDL
Sep 17 at 14:40
• @Kaddath programming-puzzle is on-topic here.
– qwr
Sep 17 at 18:20

options(prompt="\U202E")


Uses RTL Override at the end to make all following input appear reversed. I tried entering the raw character in a string but it turns into a period for some reason. Tested with RStudio 1.2.1335 and R 3.6.3 on Ubuntu 20.04, but does not work in my terminal GNOME Terminal 3.36.2 which appears to do some kind of character stripping unless the character is printable. Note that default R prompt is "> " which works in GNOME Terminal and can be replicated to make it less suspicious.

Also Al and R sound like "L" and "R".

– JDL
Sep 19 at 10:14

# R, 28 bytes

Sys.setlocale("LC_ALL","ja")


Try it online! (doesn't work)

I give it a try even if I don't know R and cannot test it on my computer.. If this doesn't work, please tell me and I will delete the answer, because it spoils the trick Al used

• I don't think this would work; it is an attempt to set the locale to Japanese, which could definitely be interpreted as "setting up your R session", but wouldn't explain why the numeric output was the way it was.
– JDL
Sep 17 at 15:04
• @JDL because it's a right to left language, as I told, I suspected it wouldn't work like this Sep 17 at 15:06
• I see --- it might work, my own computer refused to change the locale ("Warning message:In Sys.setlocale("LC_ALL", "ja") : OS reports request to set locale to "ja" cannot be honored") so I can't really test it. will see if any other users are able to verify (or otherwise). I hadn't realised Japanese was right-to-left; I thought it was top-to-bottom.
– JDL
Sep 17 at 15:10
• Don't worry too much that this spoils the "trick" of the question --- it's the more interesting part of the challenge how to achieve this with R's base library anyway (though you could use spoiler tags if you wanted to)
– JDL
Sep 17 at 15:12
• @JDL yes it's top to bottom, then right to left for the columns. Used this because I found on a SO answer saying that it worked for hebrew (while hebrew locale didn't) Sep 17 at 15:14