-
Notifications
You must be signed in to change notification settings - Fork 10
/
populiarity.r
32 lines (30 loc) · 1.42 KB
/
populiarity.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#how many users are going to attend the event
yes= data.frame(event=as.character(attend[,1]),populiarity=sapply(strsplit(as.character((attend[,2])),' '), length))
#how many friends said yes
attend_yes=apply((db[,1:2]),1,function(x){
fnd=strsplit(as.character(friends[which(friends$user==x[1]),]$friends),' ')[[1]]
length(which(fnd %in% strsplit(as.character(attend[(which(attend$event%in%x[2])),]$yes),' ')[[1]]))/length(fnd)
#print(paste(fnd,att))
#print(str(x))
})
#how many friends said no
attend_no=apply((db[,1:2]),1,function(x){
fnd=strsplit(as.character(friends[which(friends$user==x[1]),]$friends),' ')[[1]]
length(which(fnd %in% strsplit(as.character(attend[(which(attend$event%in%x[2])),]$no),' ')[[1]]))/length(fnd)
#print(paste(fnd,att))
#print(str(x))
})
#how many friends said maybe
attend_maybe=apply((db[,1:2]),1,function(x){
fnd=strsplit(as.character(friends[which(friends$user==x[1]),]$friends),' ')[[1]]
length(which(fnd %in% strsplit(as.character(attend[(which(attend$event%in%x[2])),]$maybe),' ')[[1]]))/length(fnd)
#print(paste(fnd,att))
#print(str(x))
})
#how many friends are invited
attend_invited=apply((db[,1:2]),1,function(x){
fnd=strsplit(as.character(friends[which(friends$user==x[1]),]$friends),' ')[[1]]
length(which(fnd %in% strsplit(as.character(attend[(which(attend$event%in%x[2])),]$invited),' ')[[1]]))/length(fnd)
#print(paste(fnd,att))
#print(str(x))
})