| as.data.frame.LifeTable {demlife} | R Documentation |
Convert a LifeTable object to a "long form" data frame.
The life table functions that are included in the data frame are controlled
by the showFun slot of the life table. If the life table
has iterations, the use of quantiles to summarise
these iterations is controlled by the showQuantiles and
prob slots.
## S3 method for class 'LifeTable' as.data.frame( x, row.names = NULL, optional = FALSE, stringsAsFactors = default.stringsAsFactors(), responseName = "value", ... ) ## S4 method for signature 'LifeTable' as.data.frame( x, row.names = NULL, optional = FALSE, stringsAsFactors = default.stringsAsFactors(), responseName = "value", ... )
x |
An |
row.names |
See |
optional |
See |
stringsAsFactors |
See |
responseName |
The name of the final column of the table. Defaults to
|
... |
Additional arguments to be passed to or from methods. |
as.data.frame is often called as a step towards exporting
a life table as a .csv file.
as.data.frame prints the dimensions of the life table in reverse
order, with the "age" dimension last. This ordering is different
from the one used by base function as.data.frame.array,
but, with life tables, is usually what is wanted.
A data.frame.
Life tables are created by function LifeTable.
mx <- dembase::ValuesOne(c(0.2, 0.05, 0.1, 0.4),
labels = c("0", "1-4", "5-9", "10+"),
name = "age")
lt <- LifeTable(mx)
lt
as.data.frame(lt)
showFun(lt) <- c("ex", "Tx")
as.data.frame(lt)
## life table with iterations
mx <- dembase::ValuesOne(c(0.2, 0.05, 0.1, 0.4),
labels = c("0", "1-4", "5-9", "10+"),
name = "age")
mx <- dembase::perturb(1000 * mx, n = 10) / 1000
lt <- LifeTable(mx)
lt
as.data.frame(lt)
showQuantiles(lt) <- FALSE
lt
as.data.frame(lt)
showQuantiles(lt) <- TRUE
prob(lt) <- c(0.1, 0.8)
lt
as.data.frame(lt)