Description Usage Arguments Slots Methods Extends Examples
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.
1 |
... |
Data to include in the object. |
.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 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")
:
signature(x =
"CheckedFrame")
: Use this instead of cinbd
.
signature(object =
"CheckedFrame")
:
signature(object =
"CheckedFrame")
:
signature(x =
"CheckedFrame")
:
signature(x =
"CheckedFrame")
: Use this instead of rbind
.
signature(object =
"CheckedFrame")
:
data.frame
Directly.
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.