How to open the source code of a function in R studio?

Hello,
I am trying to open a function in R studio to see how it works. For example, in Matlab if I want to see the code of the regression I will use the command open regress and the function is open.

This gives me the opportunity to see the code behind the function. Is this possible in Rstudio?

You can use View
Example: View(lm)

2 Likes

Or just type the name of the function without View to see the output in the console.

It doesn't work. Actually, I want to open the file sgt.
I installed the package sgt and then I run the command that you said to me but it doesn't work. Do you know the reason?

View does not open files but shows you the code of the function.
For example for the function dsgt from sgt package:

library(sgt)
View(dsgt)

Thank you very much for your quick response and answer!
It's works!!!!!!!!!!!!
Thank you again :slight_smile:

A shortcut in R Studio is to put the cursor on the function name and press F2. It's a nice feature when digging through nested functions.

4 Likes

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

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.