| collapseIntervals-LifeTable {demlife} | R Documentation |
Collapse intervals in an object of class LifeTable.
The intervals are typically age intervals, that is, age groups.
However, other intervals, other types of intervals, such as time periods,
can be collapsed instead. See the documentation for
function collapseIntervals
in package dembase for more information on collapsing intervals.
## S4 method for signature 'LifeTable,ANY,ANY,ANY,ANY,missing' collapseIntervals( object, dimension, breaks = NULL, width = NULL, old = NULL, weights, ... ) ## S4 method for signature 'LifeTable,ANY,ANY,ANY,ANY,Counts' collapseIntervals( object, dimension, breaks = NULL, width = NULL, old = NULL, weights, ... )
object |
Object of class |
dimension |
Name or index of the dimension where the intervals are found. |
breaks |
Numeric vector giving the breaks between intervals after the merging has occurred. |
width |
The length of the intervals after the merging has occurred. |
old |
The labels of the intervals to be merged. |
weights |
Object of class |
... |
Not currently used. |
In typical use, no weights argument is supplied. Instead,
collapseIntervals calculates Lx values for the life table,
values and uses them as weights.
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
collapseIntervals(lt, dimension = "age", width = 5)
collapseIntervals(lt, dimension = "age", breaks = c(1, 10))
collapseIntervals(lt, dimension = "age", old = c("0", "1-4"))
popn <- dembase::CountsOne(c(10, 80, 120, 200),
labels = c("0", "1-4", "5-9", "10+"),
name = "age")
collapseIntervals(lt, dimension = "age", width = 5, weights = popn)