user2341923
user2341923

Reputation: 4727

R function definition in Visual Studio v.s. R Gui

When I write function name without parenthesis in R Gui (e.g. library) I see the complete function definition (several pages of code); in Visual Studio 2017 environment I see only the following:

function (...) 
{
    if (nargs() == 0) {
    invisible(rtvs:::send_notification("!Library"))
}
else {
    base::library(...)
    }
}
<environment: namespace:rtvs>

Why Visual Studio shows abbreviated version? Are they equivalent? How can I get the complete function?

Upvotes: 2

Views: 102

Answers (1)

Jay Silverman
Jay Silverman

Reputation: 121

Let's investigate the code you copied in.

if (nargs() == 0) {
invisible(rtvs:::send_notification("!Library"))
}

rtvs is a Visual Studio R library. The code defaults to rtvs library-related functionality unless there are arguments and then the base::library() function is called. In this case, the function code shown is not abbreviated (... is representing any arguments that are passed to library()).

You can also tell the function is not base R code from the <environment: namespace:rtvs> environment details at the bottom.

For viewing function defintions of all function types in R, How can I view the source code for a function? has some nice answers.

Upvotes: 2

Related Questions