Why does RStudio open a function in "View" mode when requested "Go To Function Definition"?

Hi!

I have been using RStudio IDE for some time now and and I have not been able to clarify why the following is happening.

Let's say I have some functions created by myself and loaded into the environment by "sourcing" the corresponding script.

Once loaded into the environment, I ofently want to modify the function and I click "F2" to "Go To function Definition" and from there I am directly able to modify the function, save the script and re-source to have the function updated and running.

Many times, I have no clue why this might happen, instead of going to the function within the script in editable mode, RStudio just opens the function in "View" mode with the icon glasses. It is not the script in which function was defined, but just the function code with no possible editing.

When this happens it is kind of annoying because I have to manually find the script where the function is defined, open it and edit it .

Is there any explanation on why sometimes it leads me to the script and sometimes it leads me to the View mode when I press F2 "Go To Function definition"? I would like to understand what triggers one behaviour or another to try to work always on the go to edit mote.

Thanks!

RStudio will take you to your script if the following are both true:

  1. The function has source references.
  2. The copy of the function in the script matches the copy of the function in the source references.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.