CheckedFrame: Class 'CheckedFrame'

Description Usage Arguments Slots Methods Extends Examples

Description

Creates a new object directly extended data.frame, but with constrains that require columns. This class can be used to ensure that data frames have a specific structure.

Usage

1

Arguments

...

Data to include in the object.

Slots

.Data:

Object of class "list"

checks

Object of class list containing function elements. Each function in the list should take one argument, and return logical.

names:

Object of class "character" Column names

row.names:

Object of class "data.frameRowLabels" Row names

.S3Class:

Object of class "character" Name of S3Class

Methods

Methods commonly used with data frames are defined to return "CheckedFrame" objects where appropriate, or throw errors if they would create an invalid "CheckedFrame" object.

[<-

signature(x = "CheckedFrame"):

[

signature(object = "CheckedFrame"): Returns a "CheckedFrame" object if the returned object is valid, otherwise returns a data.frame.

[[<-

signature(x = "CheckedFrame"):

$<-

signature(x = "CheckedFrame"):

cbind2

signature(x = "CheckedFrame"): Use this instead of cinbd.

colnames<-

signature(object = "CheckedFrame"):

dimnames<-

signature(object = "CheckedFrame"):

names<-

signature(x = "CheckedFrame"):

rbind2

signature(x = "CheckedFrame"): Use this instead of rbind.

rownames<-

signature(object = "CheckedFrame"):

Extends

data.frame

Directly.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
checks <- TableChecks(columns =
                      ColumnCheckList(a = ColumnChecks(classtype="numeric",
                                        constraints =
                                        FunctionList(function(x) x > 0)),
                                      b = ColumnChecks(classtype="ANY"),
                                      c = ColumnChecks(classtype="factor")))
foo <-
  CheckedFrame(data.frame(a = runif(3), b = runif(3), c = letters[1:3]),
               checks = checks)
# works just like a normal data.frame
show(foo)
summary(foo)
# errors
try(foo$a <- as.character(foo$a))
try(foo["a", 1] <- -1)
try(foo$a <- NULL)
# errors
try(foo$b <- as.character(foo$b))
try(foo$d <- runif(3))

jrnold/r-checker documentation built on May 20, 2019, 1:04 a.m.