Object Browser

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Object Browser

wxffxw
What's the best object browser?

Dear all,

I have tried all the popular R IDE or editors like Eclipse, Komodo, JGR, Revolution...
They all have fancy fucntions like auto completion, syntax highlight....
BUT, I JUST WANT A OBJECT BROWSER!

The easiest way to view objects in R console is fix(), but you have no global view of all the objects in the workspace.
Revolution has the best object browser so far, but this thing is way too big...
Eclipse all has automatically object browser, but you can't only see the basic summary info. and it's really tricky to configure StatET.
Jgr is very handy, when you double click the object name, you can view the object in a spreadsheet like using fix(), but you have to press the "Refresh" button each time you want to see the updated objects...

So, is there any thing like the combination of eclipse and Jgr?
If not, I am interested to develope something to fulfill this simple but very important function. But right now I have no idea where to start. Any suggestions?


Peter








Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Odp: Object Browser

PIKAL Petr
Hi
I noticed that nobody answered your question yet so here is my try.

If you want to see what objects are in your environment you can use ls()
but its output is only names of objects. Here is a function I use a long
time for checking what objects are there, their type, size and possibly
rows columns. You can modify it to give you some more info but usually it
is not needed.

Regards
Petr

ls.objects <- function (pos = 1, pattern, order.by)
{
    napply <- function(names, fn) sapply(names, function(x) fn(get(x,
        pos = pos)))
    names <- ls(pos = pos, pattern = pattern)
    obj.class <- napply(names, function(x) as.character(class(x))[1])
    obj.mode <- napply(names, mode)
    obj.type <- ifelse(is.na(obj.class), obj.mode, obj.class)
    obj.size <- napply(names, object.size)
    obj.dim <- t(napply(names, function(x) as.numeric(dim(x))[1:2]))
    vec <- is.na(obj.dim)[, 1] & (obj.type != "function")
    obj.dim[vec, 1] <- napply(names, length)[vec]
    out <- data.frame(obj.type, obj.size, obj.dim)
    names(out) <- c("Type", "Size", "Rows", "Columns")
    if (!missing(order.by))
        out <- out[order(out[[order.by]]), ]
    out
}


[hidden email] napsal dne 24.09.2010 23:04:20:

>
> What's the best object browser?
>
> Dear all,
>
> I have tried all the popular R IDE or editors like Eclipse, Komodo, JGR,
> Revolution...
> They all have fancy fucntions like auto completion, syntax highlight....
> BUT, I JUST WANT A OBJECT BROWSER!
>
> The easiest way to view objects in R console is fix(), but you have no
> global view of all the objects in the workspace.
> Revolution has the best object browser so far, but this thing is way too
> big...
> Eclipse all has automatically object browser, but you can't only see the
> basic summary info. and it's really tricky to configure StatET.
> Jgr is very handy, when you double click the object name, you can view
the
> object in a spreadsheet like using fix(), but you have to press the
> "Refresh" button each time you want to see the updated objects...
>
> So, is there any thing like the combination of eclipse and Jgr?
> If not, I am interested to develope something to fulfill this simple but
> very important function. But right now I have no idea where to start.
Any

> suggestions?
>
>
> Peter
>
>
>
>
>
>
>
>
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/Object-Browser-
> tp2594912p2594912.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odp: Object Browser

wxffxw
Thanks very much for your reply, Petr. That's a nice function.
Also, I found "gvarbrowser" function in package "gWidgest" is really a good one. It's GUI and yet extendable.

library(gWidgets)
options(guiToolkit="RGtk2")
gvarbrowser(cont=gwindow("Object browser"))

I highly recommend to anyone who is seeking a GUI object browser. You can embed above codes to your .Rprofile or add it to R console menu using winMenuAdd function. Recently, John Verzani has done some wonderful work to make it even better, and have uploaded the newest package to CRAN. Thanks John!


Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odp: Object Browser

Douglas Bates-2
In reply to this post by PIKAL Petr
On Mon, Sep 27, 2010 at 3:04 AM, Petr PIKAL <[hidden email]> wrote:

> Hi
> I noticed that nobody answered your question yet so here is my try.
>
> If you want to see what objects are in your environment you can use ls()
> but its output is only names of objects. Here is a function I use a long
> time for checking what objects are there, their type, size and possibly
> rows columns. You can modify it to give you some more info but usually it
> is not needed.
>
> Regards
> Petr
>
> ls.objects <- function (pos = 1, pattern, order.by)
> {
>    napply <- function(names, fn) sapply(names, function(x) fn(get(x,
>        pos = pos)))
>    names <- ls(pos = pos, pattern = pattern)
>    obj.class <- napply(names, function(x) as.character(class(x))[1])
>    obj.mode <- napply(names, mode)
>    obj.type <- ifelse(is.na(obj.class), obj.mode, obj.class)
>    obj.size <- napply(names, object.size)
>    obj.dim <- t(napply(names, function(x) as.numeric(dim(x))[1:2]))
>    vec <- is.na(obj.dim)[, 1] & (obj.type != "function")
>    obj.dim[vec, 1] <- napply(names, length)[vec]
>    out <- data.frame(obj.type, obj.size, obj.dim)
>    names(out) <- c("Type", "Size", "Rows", "Columns")
>    if (!missing(order.by))
>        out <- out[order(out[[order.by]]), ]
>    out
> }

An alternative for the command line interface is

ls.str()

which combines ls() and a very brief version of str() as applied to
each of the objects.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Object Browser

Vitalie S.-2
In reply to this post by wxffxw
wxffxw <[hidden email]> writes:

> So, is there any thing like the combination of eclipse and Jgr?
> If not, I am interested to develope something to fulfill this simple but
> very important function. But right now I have no idea where to start. Any
> suggestions?

If you are interested in developing such a browser,  you might try to contact
Ian Fellows the developer of Deducer (www.deducer.org). I am not using it myself
but it looks like there is an API for extensions and in addition Deducer works in
many IDEs (if not all).

I have in plan to write a tree like visual object inspector for ESS,  but it
will take some time.

If you manage to start the project, try to keep in mind that "object browser" is
actually an "environment inspector" so it could be used to inspect environments
in an hierarchical fashion. Such approach would be useful during a
debug session for instance.

Also the same code might be potentially useful for inspection of S4/S3 class
hierarchy, multilevel lists, proto hierarchies,  Rjava,  cpp or whatever object or
collections with tree-likes structure. So generality is relay important here.

Cheers,
Vitally.

>
> Peter

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odp: Object Browser

wampeh
In reply to this post by wxffxw
How do I get gvarbrowser to display only data.frame named, say "atab1" or
"atab2" or "atab*"?

Also, how do I turn off the selection pull down box?


#I tried:
mydefaultclasses <-  list("Data sets1"=c("data.frame")   )
# ----
# Then
v <- gvarbrowser(  container =gwindow("Object broser"),
gWidgets:gvarbrowser_classes=mydefaultclasses )

#--
# but it does not seem to work

#I also tried:
options("gWidgets:gvarbrowser_classes"=mydefaultclasses)

#then
v <- gvarbrowser(  container =gwindow("Object broser"))

#this too did not work

#I would simply like to display the variable browser window for data.frame
"atab1" (say).

Thank you



--
View this message in context: http://r.789695.n4.nabble.com/Object-Browser-tp2594912p4650511.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odp: Object Browser

Liviu Andronic
On Fri, Nov 23, 2012 at 6:44 AM, wampeh <[hidden email]> wrote:
> How do I get gvarbrowser to display only data.frame named, say "atab1" or
> "atab2" or "atab*"?
>
> Also, how do I turn off the selection pull down box?
>
Two remarks. If you hope to get an answer it would be a good idea to
CC John Verzani, maintainer of gWidgets.

Give RStudio a try as it comes with a built-in object browser.

Liviu



>
> #I tried:
> mydefaultclasses <-  list("Data sets1"=c("data.frame")   )
> # ----
> # Then
> v <- gvarbrowser(  container =gwindow("Object broser"),
> gWidgets:gvarbrowser_classes=mydefaultclasses )
>
> #--
> # but it does not seem to work
>
> #I also tried:
> options("gWidgets:gvarbrowser_classes"=mydefaultclasses)
>
> #then
> v <- gvarbrowser(  container =gwindow("Object broser"))
>
> #this too did not work
>
> #I would simply like to display the variable browser window for data.frame
> "atab1" (say).
>
> Thank you
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Object-Browser-tp2594912p4650511.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



--
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odp: Object Browser

jverzaniNWBKZ
If gvarbrowser isn't quite to your liking, it isn't so hard to build your own variable browser. This uses a slight modification of Petr's function and wraps in a gWidgets interface. Modify his function to display what info you want and add a handler to the tbl object to have some action associated with a user selection:


ls.objects <- function (pos = 1, pattern, order.by)
{
    napply <- function(names, fn) sapply(names, function(x) fn(get(x,
        pos = pos)))
    names <- ls(pos = pos, pattern = pattern)
    obj.class <- napply(names, function(x) as.character(class(x))[1])
    obj.mode <- napply(names, mode)
    obj.type <- ifelse(is.na(obj.class), obj.mode, obj.class)
    obj.size <- napply(names, object.size)
#    obj.dim <- t(napply(names, function(x) as.numeric(dim(x))[1:2]))
#    vec <- is.na(obj.dim)[, 1] & (obj.type != "function")
#    obj.dim[vec, 1] <- napply(names, length)[vec]
    out <- data.frame(names, obj.type, obj.size, stringsAsFactors=FALSE)#, obj.dim)
    names(out) <- c("Name", "Type", "Size")#, "Rows", "Columns")
    if (!missing(order.by))
        out <- out[order(out[[order.by]]), ]
    out
}


library(gWidgets)
options(guiToolkit="RGtk2")

w <- gwindow()
g <- ggroup(cont=w, horizontal=FALSE)
bg <- ggroup(cont=g)
glabel("Pattern:", cont=bg)
flt <- gedit("", cont=bg, expand=TRUE)
tbl <- gtable(ls.objects(), cont=g, expand=TRUE)
bg <- ggroup(cont=g)
addSpring(bg)
ref <- gbutton("refresh", cont=bg)

update_gui <- function(...) {
  pat <- svalue(flt)
  tbl[] <- ls.objects(pattern=pat)
  TRUE                                  # for task callback
}

lapply(list(flt, ref), addHandlerChanged, handler=update_gui)

This will refresh when the user updates the pattern to filter by or the refresh button.

One can have it refresh when the global environment changes by adding a task callback:

addTaskCallback(update_gui)

But this can slow things up if the workspace is large. The RStudio object browser has a very fast way to see if there are changes to the objects it is monitoring but this is done in C++ code.

Loading...