ASTVariable {tangram}R Documentation

A Variable in an Abstract Syntax Tree (AST)

Description

A Variable in an Abstract Syntax Tree (AST)

A Variable in an Abstract Syntax Tree (AST)

Format

R6Class object.

Details

This node represents a variable of interest in the AST. A variable's name is recorded in the value field, and must conform to the rules of identifiers in R. This class inherits from ASTNode.

Methods

new(identifier, format=NA, type=NA)
terms()

Returns the node

distribute()

Applies the distributive property to the node, and returns the resulting node.

string()

Returns the string formula of the node

name()

Return a human representation of a node

reduce(data)

Given a set of data, perform the logical reduction of the current node.

Super class

tangram::ASTNode -> ASTVariable

Public fields

data

The associated data post reduction

type

The identified type of this node (defaults: Categorical, Numeric)

Methods

Public methods

Inherited methods

Method new()

This method creates an AST node representing a variable of a given identifier. An optional format consisting of a string of a number or a c-style printf string. An option type denoting a forced type cast of that variable.

Usage
ASTVariable$new(identifier, format = NA, type = NA)
Arguments
identifier

(character) Variable name

format

(character, numeric) Formatting directive

type

(character) any additional type information


Method factors()

Returns all terminal nodes under this. Since this is a terminal node, returns self

Usage
ASTVariable$factors()

Method name()

Returns the text name of this node. For an intercept, returns "All"

Usage
ASTVariable$name()

Method string()

Returns name of variable with optional format and type information

Usage
ASTVariable$string()

Method reduce()

Given a data.frame, associates correct variable with this node

Usage
ASTVariable$reduce(d)
Arguments
d

(data.frame) data.frame to reduce


Method clone()

The objects of this class are cloneable with this method.

Usage
ASTVariable$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

ASTVariable$new("x", "2", "Continuous")$string()


[Package tangram version 0.8.2 Index]