# Create small px object example
x0 <- px(subset(population_gl, age == "65+"))
px_data(x0)
# Add total level to one variable
x1 <- px_add_totals(x0, "gender")
px_data(x1)
# Add total level to multiple variables
x2 <- px_add_totals(x0, c("gender", "age"))
px_data(x2)
# The name of the total level can be changed with px_elimination()
x3 <-
x0 |>
px_elimination("T") |>
px_add_totals("gender")
px_data(x3)
Run the code above in your browser using DataLab