Error when creating a ratetable in R using the relsurv package

Hello!

I'm trying to create a ratetable in R using the relsurv package with the mortality rates data I've constructed, but I keep getting the following error:

Here’s the code I’m using:

Defining the variables for age, year, and sex

age <- 0:10 # Ages from 0 to 10
year <- 2017:2019 # Years from 2017 to 2019
sex <- c("male", "female") # Sex (male and female)

Creating a mortality rate array with random values

tasso_mortalita_array <- array(runif(66, min = 0.0001, max = 0.0015),
dim = c(length(age), length(year), length(sex)),
dimnames = list(age = as.character(age),
year = as.character(year),
sex = sex))

Creating the ratetable

pop_ratetable <- ratetable(
tasso_mortalita_array,
dimnames = dimnames(tasso_mortalita_array), # Using the correct dimnames
dimid = c("age", "year", "sex"), # Dimension identifiers
factor = c(0, 0, 1), # 0 = continuous for age and year, 1 = categorical for sex
type = c(2, 3, 1), # Dimension types
cutpoints = list(
0:10, # Age from 0 to 10
as.Date(paste(2017:2019, "-01-01", sep = "")), # Years as Date
NULL # No cutpoint for sex
)
)

The error message I receive is:

Error in ratetable(tasso_mortalita_array, dimnames = dimnames(tasso_mortalita_array), :
Aguments do not all have the same length (arg 2)

What I’ve checked so far:**

  1. The dimensions of the mortality_array seem correct (11 ages, 3 years, 2 sexes).
  2. The dimnames and cutpoints are also defined properly according to the documentation.

Can anyone help me understand why I am getting this error and how to fix it?

Thank you for your help!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.