Closed jcarlis3 closed 7 years ago
I agree, this is not an ideal situation for View
and I struggled with the best way to implement this (as an occasional user of the View pane in Rstudio myself).
I think having a View
method for jagsUI objects is useful because frequently they can be quite large and cannot be easily viewed in the console. Unfortunately View
is not a generic function in R, so I had to turn it into one so I could create a method for jagsUI
objects. In the new default method for View
(that non-jagsUI objects use) I call utils::View
, as you note (see cc06446).
Unfortunately, RStudio only properly sets up the View pane when the standard View
function is called directly. It doesn't work if you call utils::View
, you get the fallback popup window instead. So, the new generic View ends up with the popup window.
I don't think there is a "fix" for this other than 1) RStudio changes to properly recognize any call to utils::View
and route it to the tab (I doubt this would be a priority for them...) or 2) I name the View
function in jagsUI
something else like View.jagsUI
, which would not overwrite the existing View
function. That makes it less likely that most people find the functionality. I'm guessing you would lean towards option 2.
Ken, thanks for the quick response and explanation. Yes, I would lean towards option 2, but I understand your reasons for wanting to stick with View
.
At this time I'm going to keep View
as currently implemented but will revisit if there's enough interest.
It took me quite a while to figure out that this behaviour has nothing to do with RStudio but is caused by jagsUI
. Given that most R users probably use Rstudio as IDE, and viewing a data.frame is such a common task, I don't think that this is a good design choice. I really appreciate the time and effort you put into developing jagsUI
, but for me it's a deal breaker and I am now using rjags
instead.
Ultimately I agree, although it is pretty frustrating to have to write code to cater to a specific IDE. This view method has been removed in the Github version of jagsUI.
Thanks for the quick reply, Ken! Will give it a try.
First off, thanks for creating a very useful package.
The
View
function (added in version 1.4.4) might cause some unintended heartburn for RStudio users.RStudio calls
View
(typically from the baseutils
package) to launch their interactive "Data Viewer" pane when you click on a data.frame object in the Environment pane. However, because functions from base packages such asutils
are masked if a user-loaded package has a function of the same name, the click-to-view functionality of RStudio is altered whenjagsUI
is loaded.I understand that one can explicitly call
utils::View
, but because most users just click the data.frame name within RStudio's Environment pane to launch the Data Viewer (and RStudio runsView
without them knowing), I expect RStudio users will be surprised.A reproducible example (if run from RStudio).
The typical RStudio Data Viewer with filtering, sorting, etc.
A static view of the data.frame