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

#1

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?

0 Likes

#2

You can use View
Example: View(lm)

0 Likes

#3

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

0 Likes

#4

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?

0 Likes

#6

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)

0 Likes

#7

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

0 Likes

#8

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.

2 Likes

#9

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:

0 Likes

closed #10

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.

0 Likes