trComplete {TinnR}R Documentation

Get a completion list for a R code fragment

Description

A list with matching items is returned in a string.

Usage

  trComplete(code, file=NULL, givetype=FALSE, sep="|")

Arguments

code A piece of R code (in a character string) to analyze.
file A file where to return the result ("", or NULL for none). You can use "clipboard" to send the result to the clipboard under Windows only.
givetype Return also the type of each object in the completion list (possibly to use set a different icon in the list displayed by the external program).
sep Separator to use between items in the file (if file is not NULL).

Details

The completion list is context-dependent, and it is calculated as if the code was entered at the command line.

If the code ends with $, then the function look for items in a list or data.frame whose name is the last identifier.

If the code ends with @, then the function look for slots of the corresponding S4 object.

If the code ends with ::, then it looks for objects in a namespace.

If the code ends with a partial identifier name, the function returns all visible matching keywords.

There are other situations where the completion can be calculated, see the help of rc.settings().

Value

A string with the completion list (items separated by 'sep'), or an unique string completing unambiguously the current code, starting with 'sep'.

Note

This function uses utils:::.win32consoleCompletion() as completion engine, then, it makes the result compatible with old version of trComplete().

Author(s)

Adaptations: Jose Claudio Faria joseclaudio.faria@gmail.com
Original author: Philippe Grosjean phgrosjean@sciviews.org

See Also

Complete CallTip, trCallTip trDDEInstall

Examples

  ## Not run: 
    ## a data.frame
    data(iris)
    trComplete("item <- iris$")
    trComplete("item <- iris[[", TRUE)

    ## An S4 object
    setClass("track", representation(x = "numeric", y = "numeric"))
    t1 <- new("track", x=1:20, y=(1:20)^2)
    trComplete("item2 <- t1@", TRUE)

    ## A namespace
    trComplete("utils::")

    ## A partial identifier
    trComplete("item3 <- va", TRUE)

    ## Otherwise, a list with the content of .GlobalEnv
    trComplete("item4 <- ")
  ## End(Not run)

[Package TinnR version 1.0.3 Index]