mardi 7 juin 2016

Using R to count patterns in columns

I have a matrix in R containing 1000 columns and 4 rows. Each cell in the matrix contains an integer between 1-4. I want to know two things:

1) What is the number of columns that contain a "1", "2", "3", and "4" in any order? Ideally, I would like the code to not require that I input each possible combination of 1,2,3,4 to perform its count.

2) What is the number of columns that contain 3 of the possible integers, but not all 4?

Aucun commentaire:

Enregistrer un commentaire