Default assignment operator in R Notebook

Hi everyone,

I'm just starting to learn R and getting to know all the functionalities and shortcuts. I know that both <- and = can be used as an assignment operator in most contexts, but my question is: when I try the shortcut alt + - I always get = in the R Notebook, even though I'd rather use <-. Is there a way I can change my default operator? In the console it works fine, the issue is just in the notebook.

I'm using Windows 10 and a Portuguese keyboard (POR/PTB). Also tried Portuguese/International (POR/INTL) and it makes no difference.

Thank you!

Hi, and welcome!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers. This, however isn't one that requires it.

Until I switched over to using Linux for most of my work, I hadn't noticed this, because on my macOS I had a keyboard macro long installed to simply expand my abbreviations. And I was puzzled, as you are, why it works differently in the editor and console.

I was looking for somewhere to edit this and thought that the Global Options | Code | Snippets might provide a way, but no luck. Try typing

> fun

in the console and waiting for the autocomplete suggestions, and see that it doesn't work in the editor.

That leads me to think it can't be user modified.

1 Like

Thank you, technocrat!

When I add the same fun snippet from the console on the Mardown snippets, it actually works. So what you're saying is that there's no way I can change my default operator from = to <- in the editor?

1 Like

Sorry to be obscure: that's right, I don't think we can.

Thank you! Not a big issue, after all, typing <- requires practically the same effort of typing alt -. I guess my hand won't fall because of that :sweat_smile:

1 Like

Well. Just goes to show you

Never trust an old guy who says it can't be done.

(Addendum: especially in the unlikely event that even he can figure it out.)

snippet asn
	 <- 

Adding this macro to the snippets file actually does work if you pause just a second before before pressing tab or enter.

Go figure. I win the d'oh contest today.

1 Like

Great, thanks! It really worked.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.