October 2017
Beginner to intermediate
236 pages
7h 38m
English
The set.seed() function has been used to make the example reproducible. The matrix mat contains five columns and 10 rows representing the binary variable of each disease. The rownames() and colnames() functions have been used to give the name of the rows and columns for easy understanding.
Initially, the output matrix out is created with all NA values. The number of columns of the out matrix will be the total number of columns in the original input matrix, and the number of rows of the out matrix will be the same as the number of columns of the original input matrix.
To get all possible combinations, the first loop runs from one to a number of columns and the second loop also runs from one to a number of columns. These two loops ...