Created
December 15, 2012 02:53
-
-
Save guobl/4290930 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#炼金术士成长之路(T1): http://www.dataanalysis.cn/alchemist/alchemist.html | |
QQ <- read.csv("http://www.dataanalysis.cn/doc/a/1/qq.csv") | |
#Solution for 1th question | |
A1 <- table(QQ$id) | |
A2 <- sort(A1,decreasing = T) | |
A2[1:10] | |
# 7cha18 6cha4376 4cha3875 8cha083 4cha698 1cha65314 | |
# 1511 1238 1100 695 533 440 | |
# acha@vip.qq.com 2cha1 5cha80 3cha4233 | |
# 380 354 304 300 | |
#Solution for 2th question | |
Newid <- unique(QQ$id) | |
N <-vector(length=length(Newid)) | |
for (i in 1:length(Newid)){ | |
N[i]<-length(unique(as.Date(QQ[QQ$id==Newid[i],]$time))) | |
} | |
Result <- NULL | |
Result$id<-Newid | |
Result$num<-N | |
Result <- as.data.frame(Result) | |
Result[order(Result$num,decreasing = TRUE),][1:10,] | |
# id num | |
# 3 6cha4376 165 | |
# 5 4cha3875 152 | |
# 4 7cha18 112 | |
# 35 acha@vip.qq.com 92 | |
# 27 4cha698 89 | |
# 40 2cha1 79 | |
# 8 8cha083 75 | |
# 39 1cha457 58 | |
# 50 1cha59002 53 | |
# 1 8cha08 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment