loading...

These functions provide features required to implement a complete object browser in a GUI client.

obj_browse(
  id = "default",
  envir = .GlobalEnv,
  all.names = NULL,
  pattern = NULL,
  group = NULL,
  sep = "\t",
  path = NULL,
  regenerate = FALSE
)

obj_clear(id = "default")

obj_dir()

obj_info(id = "default", envir = .GlobalEnv, object = "", path = NULL)

obj_list(
  id = "default",
  envir = .GlobalEnv,
  object = NULL,
  all.names = FALSE,
  pattern = "",
  group = "",
  all.info = FALSE,
  sep = "\t",
  path = NULL,
  compare = TRUE,
  ...
)

write.objList(x, path, sep = "\t", ...)

# S3 method for objList
print(
  x,
  sep = NA,
  eol = "\n",
  header = !attr(x, "all.info"),
  raw.output = !is.na(sep),
  ...
)

obj_search(sep = "\t", path = NULL, compare = TRUE)

obj_menu(
  id = "default",
  envir = .GlobalEnv,
  objects = "",
  sep = "\t",
  path = NULL
)

objBrowse(
  id = "default",
  envir = .GlobalEnv,
  all.names = NULL,
  pattern = NULL,
  group = NULL,
  sep = "\t",
  path = NULL,
  regenerate = FALSE
)

objClear(id = "default")

objDir()

objInfo(id = "default", envir = .GlobalEnv, object = "", path = NULL)

objList(
  id = "default",
  envir = .GlobalEnv,
  object = NULL,
  all.names = FALSE,
  pattern = "",
  group = "",
  all.info = FALSE,
  sep = "\t",
  path = NULL,
  compare = TRUE,
  ...
)

objSearch(sep = "\t", path = NULL, compare = TRUE)

objMenu(
  id = "default",
  envir = .GlobalEnv,
  objects = "",
  sep = "\t",
  path = NULL
)

Arguments

id

The id of the object browser (you can run several ones concurrently, providing you give them different ids).

envir

An environment, or the name of the environment, or the position in the search() path.

all.names

Do we display all names (including hidden variables starting with '.')?

pattern

A pattern to match for selecting variables.

group

A group to filter.

sep

Separator to use between items (if path is not NULL).

path

The path where to write a temporary file with the requested information. Set to NULL (default) if you don't pass this data to your GUI client by mean of a file.

regenerate

Do we force to regenerate the information?

object

Name of the object selected in the object browser, components/arguments of which should be listed.

all.info

Do we return all the information (envir as first column or not (by default).

compare

If TRUE, result is compared with last cached value and the client is updated only if something changed.

...

Further arguments, passed to write.table().

x

Object returned by obj_list().

eol

Separator to use between object entries, default is to list each item in a separate line.

header

If TRUE, two-line header is printed, of the form:
Environment = environment name
Object = object name
Default is not to print header if all.info == TRUE.

raw.output

If TRUE, a compact, better suited for parsing output is produced.

objects

A list with selected items in the object browser.

Value

Depending on the function, a list, a string, a reference to an external, temporary file or TRUE in case of success or FALSE otherwise is returned invisibly.

Details

obj_browse() does the horse work. obj_dir() gets the temporary directory where exchange files with the GUI client are stored, in case you exchange data through files. You can use a better way to communicate with your GUI (you have to provide your code) and disable writing to files by using path = NULL.

obj_list() lists objects in a given environment, elements of a recursive object or function argument.

obj_search() lists the search path.

obj_clear() clears any reference to a given object browser.

obj_info() computes a tooltip info for a given object.

obj_menu()` computes a context menu for selected object(s) in the object explorer managed by the GUI client.

print.objList() print method for objList objects.

Author

Philippe Grosjean phgrosjean@sciviews.org & Kamil Barton kamil.barton@uni-wuerzburg.de

Examples

# Create various context menus
data(iris)
(obj_info(object = "iris"))
#> [1] "'data.frame':\t150 obs. of  5 variables:"                                                 
#> [2] " $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ..."                            
#> [3] " $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ..."                          
#> [4] " $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ..."                        
#> [5] " $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ..."                        
#> [6] " $ Species     : Factor w/ 3 levels \"setosa\",\"versicolor\",..: 1 1 1 1 1 1 1 1 1 1 ..."
#> [7] "Estimated size: 7.086 bytes kb"                                                           
data(trees)
# For one object
(obj_menu(objects = "iris"))
#>           widget            value
#> help        item             Help
#> example     item          Example
#> sep          sep                -
#> Functions   menu        Functions
#> print       item   |Print or show
#> generic     item       |summary()
#> generic.1   item          |plot()
#> names       item           |Names
#> str         item             |Str
#> sep.1        sep               |-
#> generic.2   item       |formula()
#> generic.3   item          |head()
#> generic.4   item          |tail()
#> View        menu             View
#> viewDef     item  |View (default)
#> require     item |Require svViews
#> report      item        Report...
#> edit        item             Edit
#> save        item       Save as...
#> Copy        menu             Copy
#> copyDef     item  |Copy (default)
#> require.1   item    |Require svIO
#> export      item        Export...
#> sep.2        sep                -
#> remove      item           Remove
#>                                                                tip
#> help                                             Help on an object
#> example                               Run examples for this object
#> sep                                                               
#> Functions                            Generic functions and methods
#> print                      Print or show the content of the object
#> generic                       Apply method summary() to the object
#> generic.1                        Apply method plot() to the object
#> names                   Names of variables contained in the object
#> str                      Compact str() representation of an object
#> sep.1                                                             
#> generic.2                     Apply method formula() to the object
#> generic.3                        Apply method head() to the object
#> generic.4                        Apply method tail() to the object
#> View                                               View the object
#> viewDef                               Default view for this object
#> require                                Require the package svViews
#> report                            Prepare a report for this object
#> edit                                                Edit an object
#> save                                                Save to a file
#> Copy                              Copy the object to the clipboard
#> copyDef         Copy this object to the clipboard (default format)
#> require.1                                 Require the package svIO
#> export                                       Export data to a file
#> sep.2                                                             
#> remove    Remove (permanently!) one or several objects from memory
#>                         code icon checked disabled hidden options
#> help              help(iris)        FALSE    FALSE  FALSE        
#> example        example(iris)        FALSE    FALSE  FALSE        
#> sep                                 FALSE    FALSE  FALSE        
#> Functions                           FALSE    FALSE  FALSE        
#> print                   iris        FALSE    FALSE  FALSE        
#> generic        summary(iris)        FALSE    FALSE  FALSE        
#> generic.1         plot(iris)        FALSE    FALSE  FALSE        
#> names            names(iris)        FALSE    FALSE  FALSE        
#> str                str(iris)        FALSE    FALSE  FALSE        
#> sep.1                               FALSE    FALSE  FALSE        
#> generic.2      formula(iris)        FALSE    FALSE  FALSE        
#> generic.3         head(iris)        FALSE    FALSE  FALSE        
#> generic.4         tail(iris)        FALSE    FALSE  FALSE        
#> View                                FALSE    FALSE  FALSE        
#> viewDef           view(iris)        FALSE     TRUE  FALSE        
#> require     require(svViews)        FALSE    FALSE  FALSE        
#> report       guiReport(iris)        FALSE     TRUE  FALSE        
#> edit      iris <- edit(iris)        FALSE    FALSE  FALSE        
#> save           guiSave(iris)        FALSE    FALSE  FALSE        
#> Copy                                FALSE    FALSE  FALSE        
#> copyDef           copy(iris)        FALSE     TRUE  FALSE        
#> require.1      require(svIO)        FALSE    FALSE  FALSE        
#> export       guiExport(iris)        FALSE     TRUE  FALSE        
#> sep.2                               FALSE    FALSE  FALSE        
#> remove              rm(iris)        FALSE    FALSE  FALSE        
# For multiple objects
(obj_menu(objects = c("iris", "trees")))
#>        widget      value
#> save     item Save as...
#> remove   item     Remove
#>                                                             tip
#> save                                             Save to a file
#> remove Remove (permanently!) one or several objects from memory
#>                        code icon checked disabled hidden options
#> save   guiSave(iris, trees)        FALSE    FALSE  FALSE        
#> remove      rm(iris, trees)        FALSE    FALSE  FALSE        
# For inexistant object (return "")
(obj_info(object = "noobject"))
#> [1] ""
(obj_menu(objects = "noobject"))
#> [1] widget   value    tip      code     icon     checked  disabled hidden  
#> [9] options 
#> <0 rows> (or 0-length row.names)
rm(iris, trees)
#> Warning: object 'iris' not found
#> Warning: object 'trees' not found

# For environments
(obj_info(envir = ".GlobalEnv"))
#> [1] "Global environment\n\n          used (Mb) gc trigger  (Mb) max used  (Mb)\nNcells 1209793 64.7    2247311 120.1  2247311 120.1\nVcells 7385138 56.4   14187461 108.3 11756059  89.7"
(obj_menu(envir = ".GlobalEnv"))
#>        widget     value                                              tip
#> load     item   Load...                                   Load R objects
#> source   item Source...                                    Source R code
#> import   item Import...                                 Import data in R
#> sep       sep         -                                                 
#> detach   item    Detach Detach an object or package from the search path
#>                                 code icon checked disabled hidden options
#> load     guiLoad(pos = ".GlobalEnv")        FALSE    FALSE  FALSE        
#> source guiSource(pos = ".GlobalEnv")        FALSE    FALSE  FALSE        
#> import                   guiImport()        FALSE    FALSE  FALSE        
#> sep                                         FALSE    FALSE  FALSE        
#> detach            detach(.GlobalEnv)        FALSE     TRUE  FALSE        
(obj_info(envir = "SciViews:TempEnv"))
#> [1] "SciViews temporary variables environment"
(obj_menu(envir = "SciViews:TempEnv"))
#>        widget  value                                              tip
#> detach   item Detach Detach an object or package from the search path
#>                            code icon checked disabled hidden options
#> detach detach(SciViews:TempEnv)        FALSE     TRUE  FALSE        
(obj_info(envir = "package:datasets"))
#> [1] "Package:       datasets\nVersion:       4.4.0\nPriority:      base\nTitle:         The R Datasets Package\nAuthor:        R Core Team and contributors worldwide\nMaintainer:    R Core Team <do-use-Contact-address@r-project.org>\nContact:       R-help mailing list <r-help@r-project.org>\nDescription:   Base R datasets.\nLicense:       Part of R 4.4.0\nBuilt:         R 4.4.0; ; 2024-04-24 20:31:00 UTC; unix"
(obj_menu(envir = "package:datasets"))
#>              widget             value
#> pkgInfo        item      Package info
#> sep             sep                 -
#> detach         item            Detach
#> detachUnload   item Detach and unload
#>                                                              tip
#> pkgInfo               Show detailed information for this package
#> sep                                                             
#> detach          Detach an object or package from the search path
#> detachUnload Detach a package from the search path and unload it
#>                                         code icon checked disabled hidden
#> pkgInfo      <<<H>>>library(help = datasets)        FALSE    FALSE  FALSE
#> sep                                                 FALSE    FALSE  FALSE
#> detach              detach(package:datasets)        FALSE     TRUE  FALSE
#> detachUnload                                        FALSE     TRUE  FALSE
#>              options
#> pkgInfo             
#> sep                 
#> detach              
#> detachUnload        
# For an environment that does not exist on the search path (return "")
(obj_info(envir = "noenvir"))
#> [1] ""
(obj_menu(envir = "noenvir"))
#> [1] widget   value    tip      code     icon     checked  disabled hidden  
#> [9] options 
#> <0 rows> (or 0-length row.names)