-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
248 lines (248 loc) · 8.65 KB
/
.Rhistory
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
x <- read.csv(file=paste("C:/Users/yhuang/Desktop/CitiBike data/citibike-tripdata/citibike-tripdata/2013-07 - Citi Bike trip data.csv",sep=""), head=TRUE,sep=",")
#Remove null cases
x = x[complete.cases(x),]
x = x[x$birth.year!="\\N",]
x$birth.year = 97-as.numeric(x$birth.year)
#Create dummy for user type
x$userTypeNum[x$usertype=="Customer"] <- "1"
x$userTypeNum[x$usertype=="Subscriber"] <- "2"
id<-grep("^userTypeNum$", colnames(x))
x[,id] <- as.numeric(x[,id])
#Convert start time to hour
id = grep("^starttime$", colnames(x))
x$triphour<-as.numeric(substr(x$starttime, 12, 13))
x$weekDay <- weekdays(as.Date(x$starttime))
x$weekDay[x$weekDay=="Monday"] <- "1"
x$weekDay[x$weekDay=="Tuesday"] <- "1"
x$weekDay[x$weekDay=="Wednesday"] <- "1"
x$weekDay[x$weekDay=="Thursday"] <- "1"
x$weekDay[x$weekDay=="Friday"] <- "1"
x$weekDay[x$weekDay=="Saturday"] <- "2"
x$weekDay[x$weekDay=="Sunday"] <- "2"
id<-grep("^weekDay$", colnames(x))
x[,id] <- as.numeric(x[,id])
x$trail <- as.numeric(with(x,paste(x$start.station.id,x$end.station.id,sep="")))
colName_Lean <-c("tripduration","triphour","start.station.id","end.station.id","userTypeNum","birth.year","gender","weekDay","trail")
id <- colnames(x) %in% colName_Lean
idT <- which(id==TRUE)
idF <- which(id==FALSE)
x_lean <- x[,idT]
x <- x[,idF]
install.packages("dplyr")
library(dplyr)
n_distinct(x_lean[2])
n_distinct(1:10)
count(x_lean[2])
top_n(10)
top_n(count()x_lean[2],10)
top_n(count(x_lean[2]),10)
top_n(x_lean[2],10)
top_n(x_lean[2],1)
cor(x_lean[1],x_lean[4])
source("citiBikeFun.R")
mosthighlycorrelated(x_lean,5)
install.packages("Hmisc")
library("Hmisc")
hist(x_lean[2])
hist(x_lean[2], nclass=100)
hist(x_lean[2], nclass=300)
h<-hist(x_lean[2], nclass=300)
h
h<-hist(x_lean[3], nclass=300)
h<-hist(x_lean[9], nclass=300)
str(h)
names(h)
h$breaks
res<-hist(x_lean[9], nclass=300)
detach("package:Hmisc", unload=TRUE)
h<-hist(x_lean[9], nclass=300)
h
hist(x_lean[9], breaks=length(x_lean[9]), freq=TRUE)
list <- hist(x_lean[9], breaks=length(x_lean[9]), freq=TRUE)
list
table(x_lean[9])
slist <- sort(table(x_lean[9]))
str(table)
slist[1:10]
slist <- sort(table(x_lean[9]),decreasing = T)
slist[1:10]
slist <- sort(table(x_lean[9]),decreasing = T)[1:10]
slist
startList <- sort(table(x_lean[2]),decreasing = T)[1:10]
endList <- sort(table(x_lean[3]),decreasing = T)[1:10]
startList
startList <- sort(table(x_lean[2]),decreasing = T)[1:100]
endList <- sort(table(x_lean[3]),decreasing = T)[1:10]
startList <- sort(table(x_lean[2]),decreasing = T)[1:100]
endList <- sort(table(x_lean[3]),decreasing = T)[1:100]
startList
endList
groupResultsListByHour <- printMeanAndSdByGroup(x_lean[c(1,4,5,6,8)],x_lean[7])
res <- Reduce("+", groupResultsListByHour) / length(groupResultsListByHour)
res
groupResultsListByHour[1]
res <- Reduce("+", list(groupResultsListByHour[1],groupResultsListByHour[1])) / length(list(groupResultsListByHour[1],groupResultsListByHour[1]))
q <- list(groupResultsListByHour[1],groupResultsListByHour[1])
res <- Reduce("+", q) / length(q)
length(q)
groupResultsListByHour[[1]]
q <- list(groupResultsListByHour[[1]],groupResultsListByHour[[1]])
res <- Reduce("+", q) / length(q)
q
groupResultsListByHour
groupResultsListByHour[[length[groupResultsListByHour]+1]] <- groupResultsListByHour[2]
groupResultsListByHour[[length[groupResultsListByHour]+1]] <- groupResultsListByHour[[2]]
groupResultsListByHour[[length(groupResultsListByHour)+1]] <- groupResultsListByHour[2]
groupResultsListByHour
groupResultsListByHour[[length(groupResultsListByHour)+1]] <- groupResultsListByHour[[1]]
groupResultsListByHour
groupResultsListByHour <- list(groupResultsListByHour[1],groupResultsListByHour[2])
groupResultsListByHour
groupResultsListByHour <- printMeanAndSdByGroup(x_lean[c(1,4,5,6,8)],x_lean[7])
groupResultsListByHour
groupResultsListByHour[length(groupResultsListByHour)+1] <- groupResultsListByHour[1]
groupResultsListByHour
groupResultsListByHour$s <- groupResultsListByHour[1]
groupResultsListByHour
groupResultsListByHour$s <- groupResultsListByHour[[1]]
groupResultsListByHour
groupResultsListByHour[[length(groupResultsListByHour)+1]] <- groupResultsListByHour[[2]]
groupResultsListByHour
groupResultsListByHourFinal[[length(groupResultsListByHourFinal)+1]] <- groupResultsListByHour[[2]]
groupResultsListByHourFinal <- NA
groupResultsListByHourFinal[[length(groupResultsListByHourFinal)+1]] <- groupResultsListByHour[[2]]
groupResultsListByHourFinal <- groupResultsListByHour[1]
groupResultsListByHourFinal[[length(groupResultsListByHourFinal)+1]] <- groupResultsListByHour[[1]]
groupResultsListByHourFinal
trailListFinal <- trailList
startListFinal <- startList
length( startListFinal )
startListFinal <- list(startList)
startListFinal[[length(startListFinal)+1]] <- startList
startListFinal
rbind(a,b)
rbind(endListFinal,endListFinal)
rbind(startListFinal,startListFinal)
cbind(startListFinal,startListFinal)
dim(cbind(startListFinal,startListFinal))
cbind(startList,startList)
dim(cbind(startList,startList))
startList
dim(startList)
rbind(startList,startList)
endList <- sort(table(x_lean[3]),decreasing = T)[1:10]
trailList <- sort(table(x_lean[9]),decreasing = T)[1:10]
startList <- sort(table(x_lean[2]),decreasing = T)[1:10]
endList <- sort(table(x_lean[3]),decreasing = T)[1:10]
rbind(startList,endList)
endlist
endList
startList
cbind(startList,endList)
names(startList)
startList$name <- as.numeric(names(startList))
startList
startList$name <- names(startList)
startList
endList
endList$name <- names(endList)
endList
as.matrix(startList)
name(startList)
names(startList)
cc<-names(startList)
cc<-as.numeric(cc)
cc
na.omit(cc)
cc
cc<-na.omit(cc)
cc
cc <-as.numeric(cc)
cc
nL <- as.numeric(names(startList))
nL<-as.numeric(na.omit(nL))
nL
startList
trailList <- sort(table(x_lean[9]),decreasing = T)[1:10]
startList <- sort(table(x_lean[2]),decreasing = T)[1:10]
endList <- sort(table(x_lean[3]),decreasing = T)[1:10]
nL <- as.numeric(names(startList))
nL<-as.numeric(na.omit(nL))
nL
nL <- as.numeric(names(startList))
nL
rbind(startList,nL)
rownames(startList) <- NULL
nL <- as.numeric(names(trailList))
trailList <- rbind(trailList,nL)
rownames(trailList) <- NULL
nL <- as.numeric(names(startList))
startList <- rbind(startList,nL)
rownames(startList) <- NULL
nL <- as.numeric(names(endList))
endList <- rbind(endList,nL)
rownames(endList) <- NULL
rbind(startList,startList)
startList
startList <- sort(table(x_lean[2]),decreasing = T)[1:10]
startList
rbind(startList,startList)
startList
trailList <- sort(table(x_lean[9]),decreasing = T)[1:10]
startList <- sort(table(x_lean[2]),decreasing = T)[1:10]
endList <- sort(table(x_lean[3]),decreasing = T)[1:10]
nL <- as.numeric(names(trailList))
trailList <- rbind(trailList,nL)
rownames(trailList) <- NULL
nL <- as.numeric(names(startList))
startList <- rbind(startList,nL)
rownames(startList) <- NULL
nL <- as.numeric(names(endList))
endList <- rbind(endList,nL)
rownames(endList) <- NULL
rbind(startList,startList)
rbind(startList,endList)
cbind(startList,endList)
source("citiBikeFun.R")
myfunction(7,2013,12,2014)
View(trailList)
groupResultsListByHour
myfunction(7,2013,12,2014)
x$trail <- as.numeric(with(x,paste(x$start.station.id,x$end.station.id,sep="")))
myfunction(7,2013,12,2014)
source("citiBikeFun.R")
myfunction(7,2013,12,2014)
source("citiBikeFun.R")
myfunction(7,2013,12,2014)
debugSource('~/R/workspace/TestDir1/citiBikeFun.R')
library("car")
myfunction(7,2013,12,2014)
groupResultsListByHour <- printMeanAndSdByGroup(x_lean[c(1,4,5,6,8)],x_lean[7])
groupResultsListByGender <- printMeanAndSdByGroup(x_lean[c(1,4,6,7,8)],x_lean[5])
groupResultsListByWeekday <- printMeanAndSdByGroup(x_lean[c(1,4,5,6,7)],x_lean[8])
x$birth.year = 97-as.numeric(x$birth.year)
myfunction(7,2013,12,2014)
debugSource('~/R/workspace/TestDir1/citiBikeFun.R')
x$birth.year = 97-as.numeric(x$birth.year)
source('~/R/workspace/TestDir1/clusterFun.R')
source('~/R/workspace/TestDir1/clusterFun.R')
source('~/R/workspace/TestDir1/clusterFun.R')
source('~/R/workspace/TestDir1/clusterFun.R')
source('~/R/workspace/TestDir1/clusterFun.R')
clusteringFun(30,0.99,0.9,FALSE,FALSE,0)
plotClusterWordCloud(resultList,TRUE,5,0)
resultList <- clusteringFun(30,0.99,0.9,FALSE,FALSE,0)
plotClusterWordCloud(resultList,TRUE,5,0)
source('~/R/workspace/TestDir1/clusterFun.R')
source('~/R/workspace/TestDir1/clusterFun.R')
plotClusterWordCloud(resultList,TRUE,5,0)
source('~/R/workspace/TestDir1/clusterFun.R')
save.image("~/R/workspace/TestDir1/workspace_0410_2015.RData")
plotClusterWordCloud(resultList,TRUE,5,0)
dev.off()
workspace_0410_2015 <- read.table("~/R/workspace/TestDir1/workspace_0410_2015.RData", quote="\"")
View(workspace_0410_2015)
load("~/R/workspace/TestDir1/workspace_0410_2015.RData")
plotClusterWordCloud(resultList,TRUE,2,0)
source('~/R/workspace/TestDir1/clusterFun.R')
plotClusterWordCloud(resultList,TRUE,2,0)