Discrepancy between View and utils::View

Calling the base R function View within a package results in the following note when running devtools::check()

Following the advice to import the function View from utils breaks the functionality at least on Posit Workbench as utils::View generally results in an error in this environment.

Error in .External2(C_dataviewer, x, title) : unable to start data viewer
In addition: Warning message:
In utils::View(data.frame(a = 1)) : unable to open display

However, View(data.frame(a=1)) works as expected, opening a new tab within the IDE.
Typing ?View redirects to the View function of utils, suggesting there is only this one function called View in base R.
View and utils::View apparently are two different functions, which is probably part of the problem.
I would suggest, this inconsistent reference should be resolved or at least the note in devtools::check() removed.

(Unfortunately, I was only allowed to upload one screenshot).

its complicated; Rstudio is attaching an environment 'tools:rstudio' via the rstudioapi (I think ?) that intercepts View and will call .rs.viewHook or something lke it ; I can do this directly when in Rstudio : .rs.viewHook(NUll,head(iris),"iris")
not sure if that would help you any.

Thanks for your reply.
Your code does exactly the same for me in Posit Workbench as View(head(iris),"iris"). Calling the View function (without specifying a namespace) in the package does exactly what I desire. It is just confusing that it utils::View() doesn't work and that devtools::check() prompts me to import View from utils (which is apparently not equivalent to the function View() without namespace).
Maybe it's the note of devtools that should be adjusted.

This topic was automatically closed after 45 days. 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.