I have this group-level data.frame:
group_table <-
data.frame(where = c("01", "01", "01"),
age = c(45, 46, 47),
males = c(5, 2, 2),
females = c(2, 3, 3))
# where age males females
# 1 01 45 5 2
# 2 01 46 2 3
# 3 01 47 2 3
My task now is relatively simple: for each male
and female
grouped in this table, I want a single row in an individual-level table. The first five rows of the table should look like this:
# where age gender
# 1 01 45 male
# 2 01 45 male
# 3 01 45 male
# 4 01 45 male
# 5 01 45 male
Is there an elegant and efficient way to do it? (The resulting table will have millions of rows).