Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are the code completion incomplete in R Studio?

Tags:

r

rstudio

Example 1: Let me take mean() function. It's common to use na.rm=TRUE in the mean function. But it doesn't show up in the code completion. When I hover over the mean function, I get mean(x,...). Inside the mean function, when I hit tab key, it's the same thing. But when I go into the help for this function, it lists, x, na.rm and trim as the arguments, an then there is also '...'. So, why are these arguments not displayed in the code completion?

Example 2: Let me take the write.csv() function. When I hover over the function, I get write.csv(...). When I press tab key inside the function, I then get a bunch of arguments (x, file, append, etc.) This time, the arguments displayed in the tool tip and those in the code completion are different?

Is there a reason for behaviors like this? It just seems very inconsistent and frankly, even inconvenient to me. But I am a beginner in R so I am guessing there could be some reasoning behind this that I am not getting.

like image 475
PraGalaxy Avatar asked Mar 13 '26 06:03

PraGalaxy


1 Answers

If you hit the tab key you should get a dropdown (or dropup?) window which you can scroll down (up) with the down-arrow key until it says mean.default. Then your tooltip should display the arguments you expect.

enter image description here

The generic mean function is really a family of S3 and possibly S4 functions depending on the packages you have loaded. Only if your first or x argument is not among the classes for the generic functions will you actually be using mean.default.

like image 137
IRTFM Avatar answered Mar 14 '26 18:03

IRTFM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!