One of the well-known drawbacks in R is use of the `for` loop. This is relatively very slow compared to other software. However, if you have avoided the use of loop while doing the same task using the matrix operation, then it is a lot faster. In this recipe, you will compare a vectorized version with a `for` loop to do the same task.

# Vectorised operation versus for loop

# Getting ready

Consider a situation where you have a dataset with 500 columns representing 500 binary variables of a certain characteristic. In the dataset, you have a total of 900 observations. The objective is to calculate the frequency of 1's in each of the 500 variables and all the possible pair-wise combinations of the variables. The dataset is given...