R语言协同过滤算法下的IBCF使用疑问

在用到协同过滤算法下的ubcf和ibcf时,因为UBCF乘出来矩阵过大而放弃,但是在IBCF使用过程中对使用范围并不是很了解,具体对哪些行/表格使用较为模糊,导致图像无法显示,最终结果出错。

{

final <- read.csv(file.choose(),encoding = "UTF-8",stringsAsFactors = FALSE,header = TRUE)
final <-final[,c(1,3,4,5,6,7,8,10,11,12)]
colnames(final) = c("r1","r2","r3","r4","r5","r6","r7","r8","r9","r10")
final <- final[-which(final$r2==0&final$r3==0&final$r4==0&final$r5==0&final$r6==0&final$r7==0&final$r8==0&final$r9==0&final$r10==0),]
require(recommenderlab)
final <- as(final,"binaryRatingMatrix")
write.csv(as(final,"matrix"),"./final_matrix.csv")#导出二元矩阵
model.IBCF <- Recommender(final,method="IBCF")#建模
#导出相似度矩阵
final.model.sim <- as(model.IBCF@model$sim,"matrix")
write.csv(final.model.sim,"./final_model_sim.csv")
#利用模型对原始数据进行预测,并获得推荐长度为30的结果
recommend.IBCF <-predict(model.IBCF,final,n=30) #推荐列表
as(recommend.IBCF,"list")[1:20]# 查看前五个用户的推荐
sink("./recommend_IBCF.txt")
print(as(recommend.IBCF,"list"))
sink()
}
# 协同过滤

#利用模型对原始数据集进行预测,并获得推荐长度为30的结果
# 模型评价
# Random算法每次都随机挑选用户没有产生过行为的网站推荐给当前用户
# Popular算法则按照物品的流行度给用户推荐他没有产生过行为的网站中最热门的网站。
# IBCF算法是基于网站的协同过滤算法
# 模型评价,离线测试
# 将三种算法形成一个算法的list
algorithms <- list("random items" = list(name = "RANDOM", param = NULL),
                   "popular items" = list(name = "POPULAR", param = NULL),
                   "UserCF" = list(name = "IBCF", param = NULL))

# 将数据以交叉检验划分成K=10份,9份训练,1份测试
# given表示用来进行模型评测的项目数量,(实际数据中只能取1)
pagePath.es <- evaluationScheme(final, method = "cross-validation", k = 10, given = 1)

# 采用算法列表对数据进行模型预测与评价,其推荐值N取3, 5, 10, 15, 20, 30
pagePath.results <- evaluate(pagePath.es, algorithms, n = c(3, 5, 10, 15, 20, 25))

# 画出评价结果的图形
plot(pagePath.results, "prec/rec", legend = "topleft", cex = 0.67)

# 构建F1的评价指标
fvalue <- function(p, r) {
  return(2 * p * r / (p + r))
}

# 求各个评价指标的均值,并将其转换为数据框的形式
pagePath.ind <- ldply(avg(pagePath.results))

# 将指标第一列有关于模型的名字重新命名
pagePath.ind[, 1] <- paste(pagePath.ind[, 1], c(3, 5, 10, 15, 20, 25))

# 选取计算F1的两个指标以及有关于模型的名字
temp.pagePath <- pagePath.ind[, c(1, 6, 7)]

# 计算F1的指标,并综合所有指标
F1 <- fvalue(temp.pagePath[, 2], temp.pagePath[, 3])
pagePath.Fvalue <- cbind(pagePath.ind, F1)

# 将评价指标写入文件中
write.csv(pagePath.Fvalue, "./pagePathpredict_ind.csv", row.names = FALSE)



######RANDOM run fold/sample [model time/prediction time]
1 [0sec/0.39sec]
2 [0sec/0.43sec]
3 [0sec/0.41sec]
4 [0sec/0.45sec]
5 [0sec/0.38sec]
6 [0.01sec/0.43sec]
7 [0.02sec/0.43sec]
8 [0sec/0.4sec]
9 [0sec/0.33sec]
10 [0sec/0.38sec]
POPULAR run fold/sample [model time/prediction time]
1 [0sec/2.07sec]
2 [0sec/2.08sec]
3 [0sec/2.15sec]
4 [0sec/2.22sec]
5 [0sec/2.31sec]
6 [0sec/2.09sec]
7 [0sec/1.99sec]
8 [0.02sec/2.02sec]
9 [0sec/2.02sec]
10 [0sec/2.13sec]
IBCF run fold/sample [model time/prediction time]
1 [0.18sec/0.24sec]
2 [0.15sec/0.2sec]
3 [0.15sec/0.2sec]
4 [0.15sec/0.2sec]
5 [0.15sec/0.19sec]
6 [0.16sec/0.16sec]
7 [0.14sec/0.17sec]
8 [0.16sec/0.17sec]
9 [0.16sec/0.17sec]
10 [0.14sec/0.17sec]
图:Error in plot.window(...) : 'xlim'值不能是无限的

我的解答思路和尝试过的方法
因为后续的代码都是教科书上已经运行过的代码,所以把问题集中在了前面
final <- as(final,"binaryRatingMatrix")
建立二元矩阵的过程,因为这是一个三万多行,十列的代码,所以用IBCF,但是具体给数据索引哪几部分不太确定,更改了数次以后实在是能力有限,遂放弃。
我想要达到的结果
想要能把结果顺利运行出来,在能出图的同时最终的评价文件也能有意义。

如果可以私信的话可以把代码传给您,非计算机专业确实对此表示能力有限,如果能解决问题的话可以打赏。