I am developing R package, and wish to change the name of a function. How could I set the project up such that the function name can be changed simultaneously in all different files where the function is called? Should I use some particular editor, like Emacs? I am using RStudio.
Asked
Active
Viewed 620 times
1 Answers
1
It appears that RStudio does not currently have the capability to do global variable renaming, q.v. this page.
However, you will likely be safe just doing a find and replace in all files for the name of function followed by an open parenthesis.
For example, if your function is called myFunc
and you want to rename it to newFunc
then you can do the following replacement:
myFunc( -> newFunc(
Include the parenthesis to make sure that you are replacing only the function definition and calls, and not the string myFunc
in some other context.

Tim Biegeleisen
- 502,043
- 27
- 286
- 360
-
Thanks @TimBiegeleisen. That makes sense. If using Emacs, is there a quick way to achieve that? – SixSigma May 27 '15 at 02:11
-
As a last resort, if you have difficulty doing it in R, highlight your code, paste it into a text editor. Find and replace there. – Pierre L May 27 '15 at 02:20
-
@AaronZeng The answer to that is another question by itself, but you can [have a look here](https://www.gnu.org/software/emacs/manual/html_node/efaq/Replacing-text-across-multiple-files.html) at the Emacs documentation for how to do that. – Tim Biegeleisen May 27 '15 at 03:41