I have a cross-classification table that looks like this:
My goal is to create a one-hot encoding of this table. So there would have to be 24 rows where the outcome is 1(having heart disease) and the 'never' column is 1 and all others are 0. 35 rows where the outcome is 1 and 'occasionally' is 1 and all others are 0. And so on.
I was able to do this just by creating a data frame and using the rep function, but there has to be a more systematic way that I cannot find.
The objective of what I'm doing is to run a logistic regression of heart disease on snoring intensity. I know how to do that.
Lastly, this table is from Alan Agresti's Categorical Data Analysis textbook, if you're curious.