Hi all,
I am trying to get the all possible permutations from two categories. The raw data is:
3 categories as labels: Penalty No-penalty Money Fine
2 categories Yes or No that could be assigned to any of the categories. For example:
Penalty No-Penalty Money fine
Y Y N
N N Y
I am using this code:
s <- c('penalty','no penalty','money fine')
n <- c('Y','N')
nrow(permutations(n=3,r=3,v=s,repeats.allowed=F ))
Number of permutations should be: 6
To get the combinations, I use this code:
f<- apply(expand.grid(s, n), 1, paste, collapse=".")
result <- t(combn(f,4))
result
The result I get is no correct: It is giving me a mix of all categories with Y and No.
The final table should look like this:
Penalty No-Penalty Money fine
Y N Y
Y Y N
Y N N
N Y Y
N Y N
N N Y
Could you please advise on the code to create this summary table?