This would be handy for conflicting functions, and more generally to systematically include the package for debugging purpose or communicating the code to others. Having to write down the package manually is time consuming and could be avoided with code completion.
this question has 2 parts:
1) How to include masked functions in the completion pop-up menu ?
Example:
x magrittr::set_names() masks purrr::set_names()
while typing set_n
and tab in the text editor, we only see the unmasked function magrittr::set_names()
in the completion menu. I'd like to be able to pick the one I need from the menu.
2) How to get code completion to write down both package::function()
?
Example:
for magrittr::set_names()
when tabbing twice set_n
in the text editor, code completion only writes down the function set_names()
. I'd like to get completion to write down the full designation magrittr::set_names()
.
A suggestion list will pop up as you type or can be accessed manually by either pressing Tab or Ctrl + Space. You can adjust those settings in Global Options -> Code -> Completion. To fill in the suggested phrase you have to press either Tab or Enter, pressing Ctrl + Space with auto-completion list open will close it.
In addition, if you have typed the character sequence for a snippet and want to insert it immediately (without going through the completion list) you can press Shift+Tab.
search() function in R Language is used to get the list of all the attached packages in the R search path. Parameters: This function takes no parameters.
I agree with the other comments - what you directly ask for is a feature request for RStudio. The tab completion for function names only works for attached functions. If you attach packages, then the masking rules will apply.
However, a good solution (and the one I use) is not ever to attach packages, and call them explicitly with the full name. Here, the RStudio tab completion can also help out a lot.
Example: type mag
and hit tab. You'll get 'magrittr::' among the suggestions. Then type set
and 'magrittr::set_names' is among the top suggestions.
A little bit more typing, but it solves your problem and gives you full control over the package::function combinations you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With