-
Notifications
You must be signed in to change notification settings - Fork 1
/
measure.R
54 lines (37 loc) · 846 Bytes
/
measure.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
library(ggplot2)
library(plyr)
library(dplyr)
library(dtplyr)
library(reshape2)
library('knitr')
library(reshape2)
## Calculate Days
fn<-function(ver){
startdate <- as.Date(ver[1])
NumDays <- difftime(as.Date(ver),startdate ,units="days")
return(as.numeric(NumDays))
}
## Persistency measure
Prsistency<-function(entity){
# print(data)
st<-total_count(data)
data<-distinct_entity(st)
# print(st)
if(data[nrow(data),]$count<data[nrow(data)-1,]$count)
per=0
else
per=1
return(per)
}
historicalPersistency<-function(entity){
# print(entity)
entity$Persistency=1
for(i in 2:nrow(entity)){
temp=entity$count
# print(temp)
if(temp[i]<temp[i-1] && entity[i,]$className==entity[i-1,]$className)
entity[i,]$Persistency=0
}
# print(entity)
return(entity)
}