I am fairly new to R.
I have a data frame containing two columns with integer values. The first contains customerID's (i=1 to 60000), while the second holds product categories of purchased goods (j=1 to 14). I want to create a binary 60000x14 matrix (customerID's as rows, product categories as columns) with value 1 if customer(i) has bought product category j and value 0 if customer(i) did not buy product j.
The data frame has no empty values e.g. for customer 1, there are rows only for the j product categories bought (typically less than 14), while customer 1 may have several rows for the same category j. I have tried to create a matrix of zeros and wanted to use a loop or possibly some apply function to put in 1's, where relevant, but as yet unsuccessful. Hope someone can help :-)