expandcolumns | R Documentation |
expandcolumns takes in a matrix that has column names that are numbers. These might be years or some other integers. If there are years missing this function will insert them into a larger matrix which is then returned.
expandcolumns(x)
x |
a matrix with integers as column names. This might be a series of counts at size for a series of years or counts at age for a number of years. If some years of data are missing this function will insert empty columns into a larger matrix so that when plotted a true view of available data can be presented. If there are no missing years then the original matrix is returned. |
a matrix with integers (years) as column names is returned with no missing years, even where some years have no data.
dat <- matrix(trunc(rnorm(50, mean=20, sd=4)),nrow=10,ncol=5,
dimnames=list(1:10,c(1990,1991,1995,1997,1999)))
print(dat)
print(expandcolumns(dat))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.