What format of the form changes when copying and pasting in rstudio?

#sample select
sample_frac(mydata,n%)#random select n% sample

##############data review####

      

Just copy the above code into the rstudio script, you will find 2 more tab

added on the last line.
What is the reason?

+3


source to share


1 answer


Edit

As @Jay mentioned in the comments, the command n%

in the command is treated as a function, and since it is incomplete, it is indented from the next line.

To further confirm, try with df %in%

in a script or df >%>

and press Enter to see the cursor move to the next indented line.

To avoid simple function execution.

sample_frac(mydata,n)

      

OR

sample_frac(mydata, n %% somenumber)

      

whatever you try to do, and everything should be fine.

Original Answer



This added 2 spaces in the code when pasted into the RStudio script. I tried to paste the same text into my notes, Pycharm editor, but it didn't add any extra tabs. So he was pretty sure it was an RStudio problem.

It turns out that the padding settings in RStudio are responsible for this. To change this:

Go to Tools -> Global Options. Click the "Code" button on the left. You will see the following:

enter image description here

Uncheck Auto-indent after pasting

enter image description here

and click OK.

Now try pasting the same text. Should be allowed.

+5


source







All Articles