I use spaces to indent but RStudio always converts spaces into tabs. This is even though I have the \"Insert spaces for tab\" global option selected. Drives me batty!
<This was driving me nuts too. Here's what I found (works in Rstudio Version 1.1.383 on Windows).
Do this in your Global options. If you are using a project, do it in your Project Options as well (as pointed out by mowshowitz).
To see what is going on, select Global Options > Code > Display > Show whitespace characters. If you have "Insert spaces for tab" checked, it appears to truly insert spaces, but it forces your cursor to treat one tab-width's worth of spaces as a single character in the editor. By setting Tab width to 1, you can get around this limitation.