Learn R Programming

SciViews (version 0.8-8)

Complete: Get a completion list for a R code fragment

Description

A list with matching items is returned in a string.

Usage

Complete(code, givetype = FALSE, fieldsep = "|")

Arguments

code
A fraction of R code needing completion
givetype
Do we append the type of each entry to the list?
fieldsep
The separator to use between the item and its type

Value

  • A string with the completion list

Details

The completion list is context-dependent, and it calculated as if the code was entered at the command line. If the code ends with $ or [[, then the function look for items in a list or data.frame whose name is the last idfentifier. If the code ends with @, then the function look for slots of the corresponding S4 object. If the code ends with a partial identifier name, the function returns all visible matching keywords. In all other situations, the function returns a list of the objects in .GlobalEnv.

See Also

guiComplete

Examples

Run this code
## a data.frame
    data(iris)
	cat(Complete("item <- iris$"), "")
	cat(Complete("item <- iris[[", TRUE), "")
	
	## An S4 object
    setClass("track", representation(x = "numeric", y = "numeric"))
    t1 <- new("track", x=1:20, y=(1:20)^2)
    cat(Complete("item2 <- t1@", TRUE), "")
    
    ## A partial identifier
    cat(Complete("item3 <- va", TRUE), "")
    
    ## Otherwise, a list with the content of .GlobalEnv
    cat(Complete("item4 <- "), "")

Run the code above in your browser using DataLab