Hi, I have got two dataframes:
table3by2 <- tibble::tribble(
~Parent_smoking, ~Child_Yes, ~Child_No,
"Both", 401, 1381,
"One", 417, 1824,
"Neither", 189, 1169
)
dat1 <- structure(list(
Parent = c(
"Both", "Both", "One", "One", "Neither",
"Neither"
), Child = c("Yes", "No", "Yes", "No", "Yes", "No"),
Counts = c("401", "1381", "417", "1824", "189", "1169")
), row.names = 2:7, class = "data.frame")
I would like to de-aggregate these data to the desired, following shape:

or instead of Yes or No coded like 0 and 1 and by analogy for Parent_smoking group 1, 2, 3 as well.
Thank you for any help.