本文介绍了在R中使用选择功能错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获得用户最常播放的歌曲。在csv文件中我想要的三个字段是userId,songId和playCount,但是select函数给出一个错误:
I want to get the song that user's play most frequently. The three fields I want in the csv file are userId,songId and playCount but the select function is giving an error:
c 每个组A more suitable dplyr function in this case is filter. Here we select rows where the condition playCount == max(playCount) is TRUE within each group.
df %.% group_by(userId) %.% filter( playCount == max(playCount)) # Source: local data frame [5 x 3] # Groups: userId # # userId songId playCount # 1 A 568r 85 # 2 C 34n 18 # 3 E 454j 65 # 4 D 663a 72 # 5 B 35d 84你会发现几个很好的。
You find several nice dplyr examples here.
这篇关于在R中使用选择功能错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!