Description Slots Author(s) See Also Examples
A collection of objects of class individual
can be stored
into the class cabinet
class.
The cabinet
object can be generated by the new("cabinet", ...)
and
as(data, "cabinet")
functions.
The result is essentially a list of individual
objects with an index.
Data of individual persons can be assessed by position by as list index
`[[`
or by unique id by the vector index `[`
.
.Data
A list of objects of class individual
ids
A number vector the indexes the (unique) individual id
n
Number of individuals
readonly
Logical indicating whether the cabinet is just for viewing
(TRUE
) or for editing by the user (FALSE
, the default)
created
Creation date
updated
Update date
Stef van Buuren 2016
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 | # create cabinet with 1 empty record
z <- new("cabinet")
class(z)
slotNames(z)
slotNames(z[[1]])
# create cabinet with three empty records
z <- new("cabinet", n = 3)
slotNames(z)
# create cabinet with one individual, Sally
sally <- new("individual", name = "Sally", sex = "female", id = 22L)
z <- new("cabinet", sally)
length(z)
# create cabinet with two individuals, Harry and Sally
harry <- new("individual", name = "Harry", id = as.integer(33))
z <- new("cabinet", list(harry = harry, sally = sally))
z[["harry"]]@name; z[["harry"]]@sex
z[["sally"]]@name; z[["sally"]]@sex
## Not run:
# convert all 1933 children of SMOCC in `individual` objects
library("donorloader")
smocc <- load_data(dnr = "smocc")
cab <- as(smocc, "cabinet")
smoccdemo <- cab[1:10]
# same, but not relative to WHO references
cab.who <- list2cabinet(smocc, libname = "who", prefix = "who2011", sub = "")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.