Is there a Rstudio keyboard shortcut to open the file that contains the source code for the function you wrote?

I have several packages of my own application that I used to load into my R sessions, as well as various functionality specific to a small project stored in various utils files. Let's say I know the name of a function, but I want to open the specific file that uses that function for reading and debugging. For example, in pyCharm, you can simply select the name of that function and press ctrl-b

. Is there any keyboard shortcut or function to find (and ideally automatically open) a file / line containing the definition of my function of interest?

Thank!

+3


source to share


2 answers


If you are in a package, then F2 will jump to the source file of the functions defined in that package (it would be nice if you could also go to other packages, but that hasn't worked yet). You can also use Ctrl +. search the type of all functions in the package (and go from the list).



+5


source


The only thing I know is that you can select the function name in RStudio (actually, you just need to place the cursor somewhere inside the function name) and then press F2. This will open a named tab Source Viewer

in the source pane where you can see the definition of the function. However, it does not open the file in which the function was defined. This means that you cannot edit and save the function.



I don't know for sure that there is no function to open the file where the function is defined, but I have every reason to suspect that this is not happening. When you create a script, the R expressions in that script are evaluated. If it contains function (or variable) definitions, they are stored in memory and will be available in the R session for future use. These R objects don't know where the code that defined them is stored (or if they were defined only from the command line), so I don't see an immediate way to tell RStudio where to look for the file containing the definition and open it.

+1


source







All Articles