我正在尝试将导入数据集的评分作为因素进行分类,并尝试将小于或等于3的评分标记为差,大于3标记为好
a_reviews$rating <- factor(a_reviews$rating,level = 1:5,ifelse(a_reviews$rating<=3, label= 'Bad', label='Good'))
但我收到了错误
Error in ifelse(a_reviews$rating <= 3, label = "Bad", label = "Good") :
unused arguments (label = "Bad", label = "Good")
答案 0 :(得分:0)
您不能使用相同标签的多个因子级别(例如,1,2,3都标记为&#39;不良&#39;)。你可以做点什么
a_reviews$ratinglabel <- as.factor(ifelse(a_reviews$rating<=3,"Bad","Good"))
并与之合作。