想要将推荐实验室预测列表保存为“”分隔列表的列表。我有一个相同的问题,但在这里想用一个转折来扩展它。
我已经尝试了几种方法,并在下面发现了相关但坚持将输出放入“”逗号分隔脚本的简单步骤。
library("recommenderlab")
library(stringi)
data("MovieLense")
MovieLense100 <- MovieLense[rowCounts(MovieLense) >100,]
MovieLense100
train <- MovieLense100[1:50]
rec <- Recommender(train, method = "UBCF")
rec
pre <- predict(rec, MovieLense100[101:105], n = 10)
as(pre, "list")
list1 = as(pre, "list")
cat(paste0(shQuote(list1[["291"]]),collapse=","))
以上给了我给定的用户:
"Titanic (1997)","Contact (1997)","Alien (1979)","Amadeus (1984)","Godfather, The (1972)","Aliens (1986)","Sting, The (1973)","American Werewolf in London, An (1981)","Schindler's List (1993)","Glory (1989)"
我想将用户和电影放在数据框中,其中第一列将是用户,第二列将是上述连接形式的电影