Learn R Programming

editrules (version 2.9.5)

editset: Read general edits

Description

An editset combines numerical (linear), categorical and conditional restrictions in a single object. Internally, it consists of two editmatrices and an editarray.

Usage

editset(editrules, env = new.env())

# S3 method for editset as.character(x, datamodel = TRUE, useIf = TRUE, dummies = FALSE, ...)

# S3 method for editset as.data.frame(x, ...)

# S3 method for editset c(...)

# S3 method for editset summary(object, useBlocks = TRUE, ...)

Value

editset: An object of class editset

as.data.frame: a data.frame with columns 'name' and 'edit'.

Arguments

editrules

character vector, expression vector or data.frame (see details) containing edits.

env

environment to parse categorical edits in (normally, users need not specify this)

x

an editset

datamodel

include datamodel?

useIf

return vectorized version?

dummies

return datamodel for dummy variables?

...

arguments to be passed to or from other methods

object

an R object

useBlocks

logical Summarize each block?

Details

The function editset converts a character or expression vector to an editset. Alternatively, a data.frame with a column called edit can be supplied. Function editfile reads edits from a free-form textfile.

See Also

editrules.plotting, violatedEdits, localizeErrors, getVars, disjunct, eliminate, substValue, isFeasible, contains, is.editset

Examples

Run this code

# edits can be read from a vector of expressions 
E <- editset(expression(
    if ( x > 0 ) y > 0,
    x + y == z,
    A %in% letters[1:2],
    B %in% letters[2:3],
    if ( A == 'a') B == 'b',
    if ( A == 'b') x >= 0,
    u + v == w,
    if ( u >= 0 ) w >= 0
))
E
summary(E)
as.data.frame(E)
getVars(E)
getVars(E,type='cat')
getVars(E,type='num')


## see also editfile
E <- editfile(system.file('script/edits/mixedits.R',package='editrules'))
E
summary(E)
as.data.frame(E)
getVars(E)
getVars(E,type='cat')
getVars(E,type='num')




# edits can be read from a vector of expressions 
E <- editset(expression(
    if ( x > 0 ) y > 0,
    x + y == z,
    A %in% letters[1:2],
    B %in% letters[2:3],
    if ( A == 'a') B == 'b',
    if ( A == 'b') x >= 0,
    u + v == w,
    if ( u >= 0 ) w >= 0
))
E
summary(E)
as.data.frame(E)
getVars(E)
getVars(E,type='cat')
getVars(E,type='num')


## see also editfile
E <- editfile(system.file('script/edits/mixedits.R',package='editrules'))
E
summary(E)
as.data.frame(E)
getVars(E)
getVars(E,type='cat')
getVars(E,type='num')



Run the code above in your browser using DataLab