I'm trying to calculate differences between products and users to use in a recommendation system.
Data is in two column with multiple rows, need to be transformed into rows as users and columns as products.
I tried cast function from reshape package with no success.
library(dplyr)
library(reshape2)
library(tidyr)
library(reshape)
data <- tibble("customerId" = c(1,2,3,4,1,1), productId = c(10,11,12,10,11,10))
I want to transform it to this format:
10 11 12
1 1 1 0
2 0 1 0
3 0 0 1
4 1 0 0
My main problem right now is at the time we have duplicate record, it should be counted only once, so we have 0-1 values.