Learn R Programming

editrules (version 2.2-0)

checkRows: Check rows of data.frame against edits.

Description

This is an S3 generic function for checking rows of a data.frame against a number of edit restrictions. The edits can be entered either in character data.frame or editmatrix format.

Usage

checkRows(E, dat)

## S3 method for class 'editmatrix': checkRows(E, dat)

## S3 method for class 'character': checkRows(E, dat)

## S3 method for class 'data.frame': checkRows(E, dat)

Arguments

Value

a logical vector with length equal to nrow(dat). If a row is violates no edit restrictions, TRUE otherwise FALSE

Details

If edits are represented as a character vector, the entries of E are parsed and evaluated in the environment of dat

If the edits are represented in a data.frame, the data.frame must have the format described in editmatrix. The edits are coerced to a character vector, and passed to checkRows.character.

If the edits are represented by an editmatrix (representing linear (in)equalities) verbose edits are extracted and passed on to checkRows.character

See Also

violatedEdits

Examples

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

dat <- data.frame( x = c(0,2,1)
                 , y = c(0,0,1)
                 , z = c(0,1,1)
                 )
# valid rows? editmatrix method
checkRows(E, dat)


# example using the character method.
data(women)
e <- c("height<=71", "weight/height>=2.1")
valid <- checkRows(e,women)
women[valid,]

# same example, using data.frame method
ef <- data.frame(
    name=c("rule 1", "rule 2"), 
    edit=e, 
    description=c("descr1","descr2"))
checkRows(ef,women)

Run the code above in your browser using DataLab