我尝试按照自定义的movieLense数据集进行分组
groupBy<- data.table(unifiedTbl) x<- groupBy[,list(rating=sum(rating) ,Unknown=sum(unknown) ,Action=sum(Action) ,Adventure = sum(Adventure) ,Animation = sum(Animation) ,"Children's" = sum(Children's) ),by=list(user_id,age,occupation)]
但由于儿童的我收到了一些与指定字符有关的错误如果我删除下面的部分代码,每件事情都可以
,"Children's" = sum(Children's)
现在我的问题是我如何以全名来到这个专栏?我该如何修复我的代码?
您可以使用名称不是有效语法的反引号:
`Children's` = sum(`Children's`)
当然,我建议改为创建有效的名称:
setnames(groupBy, make.names(names(groupBy)))