editmatrix: Create an editmatrix

Description Usage Arguments Details Value Note See Also Examples

Description

An editmatrix is a numerical matrix and a set of comparison operators representing a linear system of (in)equations. The function editmatrix generates an editmatrix from a character vector, an expression vector or a data.frame with at least the column edit. The function editfile reads edits from a free-form textfile, function as.editmatrix converts a matrix, a vector of constants and a vector of operators to an editmatrix

convert to matrix

Combine editmatrices

summary

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
editmatrix(editrules, normalize = TRUE)

## S3 method for class 'editmatrix'
as.data.frame(x, ...)

## S3 method for class 'editmatrix'
as.character(x, ...)

## S3 method for class 'editmatrix'
as.expression(x, ...)

## S3 method for class 'editmatrix'
as.matrix(x, ...)

## S3 method for class 'editmatrix'
c(...)

## S3 method for class 'editmatrix'
str(object, ...)

## S3 method for class 'editmatrix'
summary(object, useBlocks = TRUE, ...)

Arguments

editrules

A character or expression vecotr with (in)equalities written in R syntax. Alternatively, a data.frame with a column named edits, see details.

normalize

logical specifying if all edits should be transformed (see description)

x

editmatrix object

...

Arguments to pass to or from other methods

object

an R object

useBlocks

logical Summarize each block?

Details

By default, the editmatrix is normalized, meaning that all comparison operators are converted to one of <, <=, or ==. Users may specify edits using any of the operators <, <=, ==, >=, > (see examples below). However it is highly recommended to let editmatrix parse them into normal form as all functions operating on editmatrices expect or convert it to normal form anyway.

Value

editmatrix : An object of class editmatrix

as.data.frame a 3-column data.frame with columns 'name' and 'edit'. If the input editmatrix has a description attribute a third column is returned.

as.matrix: Augmented matrix of editmatrix. (See also getAb).

Note

since version 2.0-0, the behaviour of as.data.frame.editmatrix changed to be more symmetrical with editmatrix.data.frame and as.data.frame.editarray. Use editrules:::toDataFrame (unsupported) for the old behaviour.

See Also

editrules.plotting, violatedEdits, localizeErrors, normalize, contains, is.editmatrix, getA, getAb, getb, getOps getVars, eliminate, substValue, isFeasible

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Using a character vector to define contraints
E <- editmatrix(c("x+3*y==2*z", "x==z"))
print(E)

# Using a expression vector to define contraints
E <- editmatrix(expression(x+3*y==2*z, x==z))
print(E)

# an editmatrix also has a summary method:
summary(E)

# select rows from an editmatrix:
E <- editmatrix(c("x+3*y==2*z", "x >= z"))
E[getOps(E) == "=="]


#Using data.frame to define constraints
E.df <- data.frame(
    name =c("A","B","C"),
    edit = c("x == y",    
            "z + w == y + x",
            "z == y + 2*w"),
    description = c(
            "these variables should be equal","","")

)
print(E.df)

E <- editmatrix(E.df)
print(E)
# Using a character vector to define contraints
E <- editmatrix(c("x+3*y==2*z", "x==z"))
print(E)

# Using a expression vector to define contraints
E <- editmatrix(expression(x+3*y==2*z, x==z))
print(E)

# an editmatrix also has a summary method:
summary(E)

# select rows from an editmatrix:
E <- editmatrix(c("x+3*y==2*z", "x >= z"))
E[getOps(E) == "=="]


#Using data.frame to define constraints
E.df <- data.frame(
    name =c("A","B","C"),
    edit = c("x == y",    
            "z + w == y + x",
            "z == y + 2*w"),
    description = c(
            "these variables should be equal","","")

)
print(E.df)

E <- editmatrix(E.df)
print(E)

editrules documentation built on May 1, 2019, 6:32 p.m.