The complete project code is as follows:
set.seed(100) products <- c('A','B','C','D','E','F','G') user.a <- c( 3, 0, 2, 5, 5, 0,1) user.b <- c( 3, 5, 3, 5, 4, 2, 1) ratings.matrix <- as.data.frame(list(user.a,user.b)) names(ratings.matrix) <- c("user.a","user.b") rownames(ratings.matrix) <- products head(ratings.matrix) products <- c('A','B','C') user.a <- c(2,0,3) user.b <- c(5,2,0) user.c <- c(3,3,0) ratings.matrix <- as.data.frame(list(user.a,user.b, user.c)) names(ratings.matrix) <- c("user.a","user.b","user.c") rownames(ratings.matrix) <- products head(ratings.matrix) ratings.mat <- (as.matrix(ratings.matrix)) sim.mat <- cor(t(ratings.mat), method = "Pearson") sim.mat svd.coms <- svd(ratings.mat) user.a.vector <- svd.coms$u[1,] product.B.vector <- svd.coms$v[2,] ratings.user.a.prod.B <- user.a.vector %*% product.B.vector ratings.user.a.prod.B svd.coms$u[1,] %*% svd.coms$v[2,] install.packages("recommenderlab...