How it works…

Since the dataset was in a CSV file, after reading it into the R environment, it got stored as a data frame. In this recipe, you will use the matrix operation, so you need to convert the data frame into a matrix. That’s why, in the Getting ready section, the data frame has been converted into a matrix using the as.matrix() function.

In the next step, two functions were written, one using a for loop to calculate the frequency of each column in the dataset and also all possible pair-wise frequencies, and the other function also did the same task but it was implemented without using any loop. The second function uses a certain logic to calculate the frequency and cross-frequency, that is, if all of the variables in a dataset are binary, then if you multiply the transpose of the data matrix with the data matrix itself, it will give the desired results.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset