I am trying to use the R Studio View()
function programatically / in a package.
When I use utils::View()
, a different viewer than the R Studio viewer (it appears to be the one built-in to R
) is used, but if I use View()
(without specifying where the function is exported from), issues come up during R CMD CHECK
.
I checked the R Studio cheatsheet, but this did not show whether / from where the R Studio View()
is exported.
Simply check the checkbox next to the package name to load the package and gain access to the datasets. You can also click on the package name and RStudio will open a help file describing the datasets in this package. and press ENTER.
If you want to view the code built-in to the R interpreter, you will need to download/unpack the R sources; or you can view the sources online via the R Subversion repository or Winston Chang's github mirror. Uwe Ligges's R news article (PDF) (p. 43) is a good general reference of how to view the source code for .
You can also access go to function definition: Using the F2 keyboard shortcut. Using Ctrl+Click with the mouse. From either the source editor or the console.
RStudio replaces the utils::View function with their own function when it starts up. Their source is
function (...)
.rs.callAs(name, hook, original, ...)
<environment: 0x1036a6dc0>
You can't just copy this into your package, because it depends on things in that environment, and there's no way for your package to get it.
However, you can do this:
myView <- function(x, title)
get("View", envir = as.environment("package:utils"))(x, title)
and export myView
from your package. If you run this in RStudio, you'll get their function, if you run it anywhere else, you'll get the regular one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With