I have synthetic data in a 2*4 array with 500 observations:
datax = array(c(120, 181, 50, 43, 41, 33,24,8), dim=c(2,4))
dimnames(datax) = list(gender= c('male', 'female')
, punishment = c('None', 'Community_service', 'Youth_prison', 'Normal_prison'))
I'd like to produce a data.frame
from the table that represents the "source" of the frequency table.
I can represent it through a "Freq" column (as.data.frame(as.table(datax))
, also here) but I'd like to produce the data.frame with 500 rows and 2 columns (gender, punishment).
How would I do this in R?