| midpoints {dembase} | R Documentation |
Change "Intervals" dimscales to "Points",
replacing each interval with its midpoint. This can be useful for plotting
or calculating mean values, among other things. midpoints is
typically called by other functions, but it may
sometimes be useful to call it directly.
midpoints(object, dimension) ## S4 method for signature 'Component,ANY' midpoints(object, dimension) ## S4 method for signature 'Component,missing' midpoints(object) ## S4 method for signature 'DemographicArray,ANY' midpoints(object, dimension) ## S4 method for signature 'DemographicArray,missing' midpoints(object) ## S4 method for signature 'MetaData,integer' midpoints(object, dimension) ## S4 method for signature 'Population,ANY' midpoints(object, dimension) ## S4 method for signature 'Population,missing' midpoints(object)
object |
Object of class |
dimension |
Names or indices of dimensions to be converted. If
omitted, all dimensions with dimtype |
An object can only have a dimension with dimtype
"triangle" if the object also has age and time dimensions with
dimscale "Intervals". When midpoints is called
on an object with a triangles dimension, the dimtype for that
dimension is coerced to "state" and the dimscale is
coerced to "Categories".
Object of class DemographicArray.
library(demdata)
rates <- Values(VADeaths2)
midpoints(rates)
a <- array(1:4,
dim = c(2, 2),
dimnames = list(age = c("0-39", "40+"),
period = c("2001-2010", "2011-2020")))
x <- Counts(a)
midpoints(x)
midpoints(x, dimension = c("age", "period"))
midpoints(x, dimension = "period")
midpoints(x, dimension = 2)