Like many others, I like writing my codes on several lines and I appreciate the auto-indent feature offered by RStudio. The issue suddenly started when the word undefined
showed up in the code editor whenever I pressed Enter
as I expected an automatic indentation. It is important to mention that this does not affect the proper running of the code.
my_fun <- function(xxx){
undefined
}
NB: Actually, when I copied and pasted the code here, undefined
was not copied to! I had to manually add it. Here is another example.
library(magrittr)
mtcars %>%
undefinedhead()
Basically this is just RStudio telling you that you have not preset your tab spaces, but it is not actually dropping commands into your code.
You have the option of setting tabs to however many spaces you feel is appropriate and it allows teams to work with consistent spacing.
If you go to the main menu and click on Tools > Global Options
and on the second tab in the left column click onCode
. There you can set the spaces to meet your personal needs (or teams profile) and the undefined
message will disappear.
This photgraph shows where you can find the preferences.