forked from ntuaha/R_ETL_LAB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
512 lines (512 loc) · 28.3 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
see1 = filter(mutate(ABT,ratio =mortage_total_bal/GDP,ratio2 = mortgage_bal/GDP,ratio3 = mortgage/md_total),is.na(ratio)==FALSE)
see1 = filter(mutate(ABT,ratio =mortage_total_bal/GDP,ratio2 = mortgage_bal/GDP,ratio3 = mortgage_bal/md_total),is.na(ratio)==FALSE)
ggplot(see1, aes(time, ratio2)) +
geom_point(aes(size = mortage_total_cnt), alpha = 1/2) +
geom_smooth(method="loess") +
scale_size_area()
ggplot(see1, aes(time, ratio3)) +
geom_point(aes(size = mortage_total_cnt), alpha = 1/2) +
geom_smooth(method="loess") +
scale_size_area()
ggplot(see1, aes(time, ratio2)) +
geom_point(aes(size = mortage_total_cnt), alpha = 1/2) +
geom_smooth(method="loess") +
scale_size_area()
ggplot(see1, aes(time, ratio)) +
geom_point(aes(size = mortage_total_cnt), alpha = 1/2) +
geom_smooth(method="loess") +
scale_size_area()
ggplot(see1, aes(time, ratio2)) +
geom_point(aes(size = mortage_total_cnt), alpha = 1/2) +
geom_smooth(method="loess") +
scale_size_area()
ggplot(see1, aes(time, ratio)) +
geom_point(aes(size = mortage_total_cnt), alpha = 1/2) +
geom_smooth(method="loess") +
scale_size_area()
ggplot(see1, aes(time, ratio2)) +
geom_point(aes(size = mortage_total_cnt), alpha = 1/2) +
geom_smooth(method="loess") +
scale_size_area()
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=F)
library(gdata)
library(dplyr)
library(xts)
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=F)
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=F)
library(gdata)
install.package("gdata")
install.packages("gdata")
install.packages("dplyr")
install.packages("dplyr")
install.packages("xts")
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=F)
library(gdata)
library(dplyr)
library(xts)
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=F)
View(Correct)
View(Correct)
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=T)
#install.packages("gdata")
#install.packages("dplyr")
#install.packages("xts")
library(gdata)
library(dplyr)
library(xts)
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=T)
View(Correct)
str(Correct)
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=F)
Y = as.integer(rownames(correct))
Y = as.integer(rownames(Correct))
Correct = cbind(Correct,Y)
Correct = filter(Correct,Y>=2)
View(Correct)
View(Correct)
Correct$Y=NULL
View(Correct)
str(Correct)
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=T)
str(Correct)
rownames(Correct) = c("name",paste("V",c(1:15),sep=""))
paste("V",c(1:15),sep="")
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=T)
rownames(Correct) = c("name",paste("V",c(1:15),sep=""))
rownames(Correct) = c("name",paste("V",c(1:16),sep=""))
rownames(Correct) = c("name",paste("V",c(1:14),sep=""))
c("name",paste("V",c(1:14),sep=""))
c("name",paste("V",c(1:15),sep=""))
View(Correct)
rownames(Correct) = c("name",paste("V",c(1:16),sep=""))
row.names(Correct) = c("name",paste("V",c(1:16),sep=""))
row.names(Correct) = c("name",paste("V",c(1:15),sep=""))
colnames(Correct) = c("name",paste("V",c(1:15),sep=""))
str(Correct)
Correct = mutate(Correct,V1 = as.integer(V1),V2 = as.integer(V2))
str(Correct)
View(Correct)
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=T)
colnames(Correct) = c("name",paste("V",c(1:15),sep=""))
Correct = mutate(Correct,V1 = is.na(as.integer(V1),0),V2 = is.na(as.integer(V2),0))
Correct = mutate(Correct,V1 = ifelse(is.na(as.integer(V1)),0,V1),V2 = ifelse(is.na(as.integer(V2)),0,V2))
Correct = mutate(Correct,V1 = as.integer(V1),V2 = is.na(as.integer(V2),names = names[1:2])
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=T)
colnames(Correct) = c("name",paste("V",c(1:15),sep=""))
#Correct = mutate(Correct,V1 = ifelse(is.na(as.integer(V1)),0,V1),V2 = ifelse(is.na(as.integer(V2)),0,V2))
Correct = mutate(Correct,V1 = as.integer(V1),V2 = is.na(as.integer(V2),names = names[1:2])
View(Correct)
Correct = mutate(Correct,V1 = as.integer(V1),V2 = is.na(as.integer(V2),names = names[1:2])
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=T)
colnames(Correct) = c("name",paste("V",c(1:15),sep=""))
#Correct = mutate(Correct,V1 = ifelse(is.na(as.integer(V1)),0,V1),V2 = ifelse(is.na(as.integer(V2)),0,V2))
Correct = mutate(Correct,V1 = as.integer(V1),V2 = as.integer(V2),names = names[1:2])
View(Correct)
Correct$names
View(Correct)
Correct = mutate(Correct,V1 = as.integer(V1),V2 = as.integer(V2),name = name[1:2])
View(Correct)
View(Correct)
str(Correct)
Correct = mutate(Correct,V1 = as.integer(ifelse(is.integer(V1),V1,NA),V2 = as.integer(ifelse(is.integer(V2),V2,0),name = name[1:2])
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=T)
colnames(Correct) = c("name",paste("V",c(1:15),sep=""))
#Correct = mutate(Correct,V1 = ifelse(is.na(as.integer(V1)),0,V1),V2 = ifelse(is.na(as.integer(V2)),0,V2))
Correct = mutate(Correct,V1 = as.integer(ifelse(is.integer(V1),V1,NA),V2 = as.integer(ifelse(is.integer(V2),V2,0)),name = name[1:2])
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=T)
colnames(Correct) = c("name",paste("V",c(1:15),sep=""))
#Correct = mutate(Correct,V1 = ifelse(is.na(as.integer(V1)),0,V1),V2 = ifelse(is.na(as.integer(V2)),0,V2))
Correct = mutate(Correct,V1 = as.integer(ifelse(is.integer(V1),V1,NA)),V2 = as.integer(ifelse(is.integer(V2),V2,0)),name = name[1:2])
Correct = mutate(Correct,name = name[1:2])
Correct = mutate(Correct,V1 = as.integer(V1),V2 = as.integer(V2),name = substr(name,1,2))
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=T)
colnames(Correct) = c("name",paste("V",c(1:15),sep=""))
#Correct = mutate(Correct,V1 = ifelse(is.na(as.integer(V1)),0,V1),V2 = ifelse(is.na(as.integer(V2)),0,V2))
Correct = mutate(Correct,V1 = as.integer(V1),V2 = as.integer(V2),name = substr(name,1,2))
View(Correct)
View(Correct)
Correct_1 =filter(Correct,name <> "總")
Correct_1 =filter(Correct,name != "總")
View(Correct_1)
Correct_1 =filter(Correct,name != "總 ")
Correct_1 =filter(Correct,name != "總\t")
Correct_1 =filter(Correct,name != "總 ")
Correct = read.xls("/Volumes/AhaStorage/Project/TWFS/外存餘額市場報表.xlsx", sheet=1,stringsAsFactors=F,header=T)
colnames(Correct) = c("name",paste("V",c(1:15),sep=""))
#Correct = mutate(Correct,V1 = ifelse(is.na(as.integer(V1)),0,V1),V2 = ifelse(is.na(as.integer(V2)),0,V2))
Correct = mutate(Correct,V1 = as.integer(V1),V2 = as.integer(V2),name = substr(name,1,2))
Correct_1 =filter(Correct,name != "總 ")
View(Correct_1)
S_Correct_1 = summarise(Correct_1,sV1 = V1,sV2 = V2)
S_Correct_1 = summarise(Correct_1,sV1 = sum(V1,na.rm=T),sV2 = sum(V2,na.rm=T))
View(S_Correct_1)
Correct_2 =filter(Correct,name = "總 ")
Correct_2 =filter(Correct,name == "總 ")
CC = left_join(Correct_1,Correct_2)
View(Correct_2)
View(Correct_2)
CC = cbind(Correct_1$sV1,Correct_1$sV2,Correct_2$V1,Correct_2$V2)
View(CC)
CC = c(Correct_1$sV1,Correct_1$sV2,Correct_2$V1,Correct_2$V2)
CC = c(V1 = Correct_1$sV1,V2= Correct_1$sV2,V3= Correct_2$V1,V4= Correct_2$V2)
CC = cbind(V1 = Correct_1$sV1,V2= Correct_1$sV2,V3= Correct_2$V1,V4= Correct_2$V2)
View(CC)
CC = cbind(V1 = S_Correct_1$sV1,V2= S_Correct_1$sV2,V3= Correct_2$V1,V4= Correct_2$V2)
View(CC)
View(Correct_1)
View(Correct)
library(dplyr)
Cl_info = read.table(file='/Volumes/AhaStorage/Project/R_ETL/data/cl_info_other.csv',header=T,sep=",",stringsAsFactors=F)
Cl_info_part = select(Cl_info,data_dt,bank_nm,mortgage_bal)
#Cl_info_part2 = filter(Cl_info,mortgage_bal>1000000)
#Cl_info_part3 = filter(Cl_info,mortage = mortgage/1000000)
#Cl_info_part4 = arrange(Cl_info,mortage,desc(data_dt))
Cl_info_part5 = mutate(Cl_info,time= as.POSIXct(data_dt)) #已看過
Cl_info_part6 = group_by(Cl_info_part5,time) #先匯總
Cl_info_part7 = summarise(Cl_info_part6,
mortage_total_bal = sum(mortgage_bal, na.rm = TRUE))
GDP = read.table(file='/Volumes/AhaStorage/Project/R_ETL/data/GDP.txt',sep=",",stringsAsFactors=F,header=F)
GDP_part1 = cbind(GDP,y=1:154)
GDP_part2 = filter(GDP_part1,y>4&y<137)
colnames(GDP_part2) = c("time","GDP","GDP_yoy"
,"GDP_2006","GDP_2006_yoy",
"GDP_minus","GDP_minus_yoy","row_no")
GDP_part3= mutate(GDP_part2,GDP = as.numeric(gsub(",", "",GDP))*1000000)
GDP_part4 = mutate(GDP_part3,year=as.numeric(substr(time,0,4)),season=as.numeric(substr(time,6,6)))
GDP_part5 = select(GDP_part4,year,season,GDP)
GDP_part6 = summarise(group_by(GDP_part5,year),GDP=sum(GDP))
x=data.frame(c1 = c(1,1,2,3,4,5,5),c2 = c('A','B','C','D','E','F','G'))
y=data.frame(c1 = c(1,2,2,3,4,6,6),c2 = c('A','B','C','D','E','F','G'))
ljxy = left_join(x,y,by="c1")
ljyx = left_join(y,x,by="c1")
GDP_part7 = select(mutate(GDP_part6 , time = as.POSIXct(paste(year,'1','1',sep='-'))),time,GDP)
t1 = left_join(GDP_part7,Cl_info_part7,by="time")
t2 = filter(t1,is.na(mortage_total_bal)==FALSE)
see1 = filter(mutate(t2,ratio =mortage_total_bal/GDP),is.na(ratio)==FALSE)
library(dplyr)
Cl_info = read.table(file='/Volumes/AhaStorage/Project/R_ETL/data/cl_info_other.csv',header=T,sep=",",stringsAsFactors=F)
Cl_info_part = select(Cl_info,data_dt,bank_nm,mortgage_bal)
#Cl_info_part2 = filter(Cl_info,mortgage_bal>1000000)
#Cl_info_part3 = filter(Cl_info,mortage = mortgage/1000000)
#Cl_info_part4 = arrange(Cl_info,mortage,desc(data_dt))
Cl_info_part5 = mutate(Cl_info,time= as.POSIXct(data_dt)) #已看過
Cl_info_part6 = group_by(Cl_info_part5,time) #先匯總
Cl_info_part7 = summarise(Cl_info_part6,
mortage_total_bal = sum(mortgage_bal, na.rm = TRUE))
GDP = read.table(file='/Volumes/AhaStorage/Project/R_ETL/data/GDP.txt',sep=",",stringsAsFactors=F,header=F)
GDP_part1 = cbind(GDP,y=1:154)
GDP_part2 = filter(GDP_part1,y>4&y<137)
colnames(GDP_part2) = c("time","GDP","GDP_yoy"
,"GDP_2006","GDP_2006_yoy",
"GDP_minus","GDP_minus_yoy","row_no")
GDP_part3= mutate(GDP_part2,GDP = as.numeric(gsub(",", "",GDP))*1000000)
GDP_part4 = mutate(GDP_part3,year=as.numeric(substr(time,0,4)),season=as.numeric(substr(time,6,6)))
GDP_part5 = select(GDP_part4,year,season,GDP)
GDP_part6 = summarise(group_by(GDP_part5,year),GDP=sum(GDP))
x=data.frame(c1 = c(1,1,2,3,4,5,5),c2 = c('A','B','C','D','E','F','G'))
y=data.frame(c1 = c(1,2,2,3,4,6,6),c2 = c('A','B','C','D','E','F','G'))
ljxy = left_join(x,y,by="c1")
ljyx = left_join(y,x,by="c1")
GDP_part7 = select(mutate(GDP_part6 , time = as.POSIXct(paste(year,'1','1',sep='-'))),time,GDP)
t1 = left_join(GDP_part7,Cl_info_part7,by="time")
t2 = filter(t1,is.na(mortage_total_bal)==FALSE)
see1 = filter(mutate(t2,ratio =mortage_total_bal/GDP),is.na(ratio)==FALSE)
View(Cl_info)
View(Cl_info)
View(GDP)
View(x)
View(y)
View(see1)
library(ggplot2)
ggplot(see1, aes(time, ratio))+geom_smooth(method="loess") +
scale_size_area() +geom_point(aes(size = 20), alpha = 1/2)
View(Cl_info)
View(GDP)
library(slidify)
author(deckdir="Volumes/AhaStorage/Project/R",use_git=FALSE,open_rmd=FALSE)
library(dplyr)
Cl_info = read.table(file='/Volumes/AhaStorage/A_Project/R_ETL/data/cl_info_other.csv',header=T,sep=",",stringsAsFactors=F)
Cl_info_part = select(Cl_info,data_dt,bank_nm,mortgage_bal)
Cl_info = read.table(file='/Volumes/AhaStorage/A_Project/R_ETL/data/cl_info_other.csv',header=T,sep=",",stringsAsFactors=F)
Cl_info_part = select(Cl_info,data_dt,bank_nm,mortgage_bal)
Cl_info_part2 = mutate(Cl_info_part,time= as.POSIXct(data_dt)) #已看過
Cl_info_part3 = group_by(Cl_info_part2,time) #先匯總
Cl_info_part4 = summarise(Cl_info_part3,
mortage_total_bal = sum(mortgage_bal, na.rm = TRUE))
GDP = read.table(file='/Volumes/AhaStorage/A_Project/R_ETL/data/GDP.txt',sep=",",stringsAsFactors=F,header=F)
#GDP_part1 = cbind(GDP,y=1:154)
#GDP_part2 = filter(GDP_part1,y>4&y<137)
GDP_part1 = GDP[5:136,]
colnames(GDP_part1) = c("time","GDP","GDP_yoy"
,"GDP_2006","GDP_2006_yoy",
"GDP_minus","GDP_minus_yoy")
GDP_part2= mutate(GDP_part1,GDP = as.numeric(gsub(",", "",GDP))*1000000)
GDP_part3 = mutate(GDP_part2,year=as.numeric(substr(time,0,4)),season=as.numeric(substr(time,6,6)))
GDP_part4 = select(GDP_part3,year,season,GDP)
GDP_part5 = filter(summarise(group_by(GDP_part4,year),GDP=sum(GDP)),is.na(GDP)==FALSE)
x=data.frame(c1 = c(1,1,2,3,4,5,5),c2 = c('A','B','C','D','E','F','G'))
y=data.frame(c1 = c(1,2,2,3,4,6,6),c2 = c('A','B','C','D','E','F','G'))
ljxy = left_join(x,y,by="c1")
ljyx = left_join(y,x,by="c1")
GDP_part6 = select(mutate(GDP_part5 , time = as.POSIXct(paste(year,'1','1',sep='-'))),time,GDP)
t1 = left_join(GDP_part6,Cl_info_part4,by="time")
t2 = filter(t1,is.na(mortage_total_bal)==FALSE)
see1 = filter(mutate(t2,ratio =mortage_total_bal/GDP),is.na(ratio)==FALSE)
View(see1)
slidify("index.Rmd");
publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");
publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");
publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");
publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");
publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
author(deckdir="Volumes/AhaStorage/Project/R",use_git=FALSE,open_rmd=FALSE)
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
install.package("quantmod")
install.packages("quantmod")
library(quantmod)
getSymbols(2884, from="2014-01-01", to="2014-07-02")
, env=mystocks
getSymbols(2884, env=mystocks, from="2014-01-01", to="2014-07-02")
getSymbols("2884", env=mystocks, from="2014-01-01", to="2014-07-02")
getSymbols(c("2884"), env=mystocks, from="2014-01-01", to="2014-07-02")
getSymbols("IBM", env=mystocks, from="2014-01-01", to="2014-07-02")
getSymbols("IBM", from="2014-01-01", to="2014-07-02")
View(IBM)
input = read.table("/Users/aha/Dropbox/Project/ESB/Alert/input.dat",header=F)
View(input)
input = read.table("/Users/aha/Dropbox/Project/ESB/Alert/input.dat",header=F,sep=",")
View(input)
getSymbols("2884.TW", from="2014-01-01", to="2014-07-02")
View(`2884.TW`)
library(ggplot)
library(ggplot2)
View(input)
output = read.table("/Users/aha/Dropbox/Project/ESB/Alert/output.dat",header=F,sep=",")
p = ggplot(input,aes(x=V1,y=V2))
p+geom_line()
p = ggplot(input,aes(x=V1,y=V2))
p+geom_line()+geom_line(output,aes(x=V1,y=V2))
p+geom_line()+geom_line(data=output,aes(x=V1,y=V2))
p+geom_line()+geom_line(data=output,aes(x=V1,y=V2),colour="red")
p+geom_line()+geom_line(data=output,aes(x=V1,y=V2),colour="red")+geom_point(data=output,aes(x=V1,y=V2,colour="red",size=10))
p+geom_line()+geom_line(data=output,aes(x=V1,y=V2),colour="red")+geom_point(data=output,aes(x=V1,y=V2,colour="red",size=20))
p+geom_line()+geom_line(data=output,aes(x=V1,y=V2),colour="red")+geom_point(data=output,aes(x=V1,y=V2,colour="red",size=20))+scale_size_area()
a = getSymbols("2884.TW", from="2014-01-01", to="2014-07-02")
View(`2884.TW`)
write.csv("/Users/aha/Dropbox/Project/ESB/Alert/stock.csv",`2884.TW`)
write.csv(`2884.TW`,"/Users/aha/Dropbox/Project/ESB/Alert/stock.csv")
a = getSymbols("2884.TW", from="2012-01-01", to="2014-07-02")
write.csv(`2884.TW`,"/Users/aha/Dropbox/Project/ESB/Alert/stock.csv")
View(`2884.TW`)
rownames(`2884.TW`)
View(`2884.TW`)
row.names(`2884.TW`)
row.names(`2884.TW`)
a = `2884.TW`
View(a)
row.names(a)
str(a)
index(a)
View(a)
stock = cbind(index(a),a["2884.TW.Close"])
a["2884.TW.Close"]
a$"2884.TW.Close"
stock = cbind(index(a),a$"2884.TW.Close")
b = a$"2884.TW.Close"
b
b = a["2884.TW.Close", which.i=TRUE]
write.csv(a$"2884.TW.Close","/Users/aha/Dropbox/Project/ESB/Alert/stock.csv")
write.csv(index(a),"/Users/aha/Dropbox/Project/ESB/Alert/date.csv")
write.csv(a$"2884.TW.Close","/Users/aha/Dropbox/Project/ESB/Alert/stock.csv",header=F)
write.csv(a$"2884.TW.Close","/Users/aha/Dropbox/Project/ESB/Alert/stock.csv",col.names = F,row.names=T)
write.csv(a$"2884.TW.Close","/Users/aha/Dropbox/Project/ESB/Alert/stock.csv",row.names=T)
write.table(a$"2884.TW.Close","/Users/aha/Dropbox/Project/ESB/Alert/stock.csv",row.names=T,col.names = F,sep = ',')
write.table(a$"2884.TW.Close","/Users/aha/Dropbox/Project/ESB/Alert/stock.csv",row.names=T,col.names = F,sep = ',')
write.table(index(a),"/Users/aha/Dropbox/Project/ESB/Alert/date.csv",row.names=T,col.names = F,sep = ',')
write.table(a$"2884.TW.Close","/Users/aha/Dropbox/Project/ESB/Alert/stock.csv",row.names=F,col.names = F,sep = ',')
write.table(index(a),"/Users/aha/Dropbox/Project/ESB/Alert/date.csv",row.names=F,col.names = F,sep = ',')
input = read.table("/Users/aha/Dropbox/Project/ESB/Alert/input.dat",header=F,sep=",")
output = read.table("/Users/aha/Dropbox/Project/ESB/Alert/output.dat",header=F,sep=",")
p = ggplot(input,aes(x=V1,y=V2))
p+geom_line()+geom_line(data=output,aes(x=V1,y=V2),colour="red")+geom_point(data=output,aes(x=V1,y=V2,colour="red",size=20))+scale_size_area()
p+geom_line()+geom_line(data=output,aes(x=V1,y=V2),colour="red")+geom_point(data=output,aes(x=V1,y=V2,colour="red",size=10))+scale_size_area()
p+geom_line()+geom_line(data=output,aes(x=V1,y=V2),colour="red")+geom_point(data=output,aes(x=V1,y=V2,colour="red",size=10))
p+geom_line()+geom_line(data=output,aes(x=V1,y=V2),colour="red")+geom_point(data=output,aes(x=V1,y=V2,colour="red"))
input = read.table("/Users/aha/Dropbox/Project/ESB/Alert/input.dat",header=F,sep=",")
output = read.table("/Users/aha/Dropbox/Project/ESB/Alert/output.dat",header=F,sep=",")
p = ggplot(input,aes(x=V1,y=V2))
p+geom_line()+geom_line(data=output,aes(x=V1,y=V2),colour="red")+geom_point(data=output,aes(x=V1,y=V2,colour="red"))
library(dplyr)
Cl_info = read.table(file='/Volumes/AhaStorage/A_Project/R_ETL/data/cl_info_other.csv',header=T,sep=",",stringsAsFactors=F)
Cl_info_part = select(Cl_info,data_dt,bank_nm,mortgage_bal)
#Cl_info_part2 = filter(Cl_info,mortgage_bal>1000000)
#Cl_info_part3 = filter(Cl_info,mortage = mortgage/1000000)
#Cl_info_part4 = arrange(Cl_info,mortage,desc(data_dt))
Cl_info_part2 = mutate(Cl_info_part,time= as.POSIXct(data_dt)) #已看過
Cl_info_part3 = group_by(Cl_info_part2,time) #先匯總
Cl_info_part4 = summarise(Cl_info_part3,
mortage_total_bal = sum(mortgage_bal, na.rm = TRUE))
GDP = read.table(file='/Volumes/AhaStorage/A_Project/R_ETL/data/GDP.txt',sep=",",stringsAsFactors=F,header=F)
#GDP_part1 = cbind(GDP,y=1:154)
#GDP_part2 = filter(GDP_part1,y>4&y<137)
GDP_part1 = GDP[5:136,]
colnames(GDP_part1) = c("time","GDP","GDP_yoy"
,"GDP_2006","GDP_2006_yoy",
"GDP_minus","GDP_minus_yoy")
GDP_part2= mutate(GDP_part1,GDP = as.numeric(gsub(",", "",GDP))*1000000)
GDP_part3 = mutate(GDP_part2,year=as.numeric(substr(time,0,4)),season=as.numeric(substr(time,6,6)))
GDP_part4 = select(GDP_part3,year,season,GDP)
GDP_part5 = filter(summarise(group_by(GDP_part4,year),GDP=sum(GDP)),is.na(GDP)==FALSE)
x=data.frame(c1 = c(1,1,2,3,4,5,5),c2 = c('A','B','C','D','E','F','G'))
y=data.frame(c1 = c(1,2,2,3,4,6,6),c2 = c('A','B','C','D','E','F','G'))
ljxy = left_join(x,y,by="c1")
ljyx = left_join(y,x,by="c1")
GDP_part6 = select(mutate(GDP_part5 , time = as.POSIXct(paste(year,'1','1',sep='-'))),time,GDP)
t1 = left_join(GDP_part6,Cl_info_part4,by="time")
t2 = filter(t1,is.na(mortage_total_bal)==FALSE)
see1 = filter(mutate(t2,ratio =mortage_total_bal/GDP),is.na(ratio)==FALSE)
eg0 = mutate(Cl_info_part2,year = format(time,"%Y"))
eg1 = summarise(group_by(Cl_info_part2,time) , mortage_mean_bal = mean(mortgage_bal, na.rm = TRUE))
eg2_1 = filter(Cl_info_part2,mortgage_bal >0)
eg2_2 = summarise(group_by(eg2_1,time),count = n())
eg3_1 = filter(Cl_info_part2,mortgage_bal >0)
eg3_2 = mutate(eg3_1,year = format(time,"%Y"))
eg3_3 = summarise(group_by(eg3_2,year),count = n_distinct(bank_nm))
eg4 = summarise(group_by(Cl_info_part2,time),val = max(mortgage_bal))
eg5 = summarise(group_by(Cl_info_part2,time),val = last(bank_nm,order_by=mortgage_bal))
eg6_1 = arrange(Cl_info_part2,time,desc(mortgage_bal))
eg6_2 = summarise(group_by(eg6_1,time),val = nth(bank_nm,2))
library(ggplot2)
ggplot(see1, aes(time, ratio)) +
geom_point(aes(size = mortage_total_cnt), alpha = 1/2) +
geom_smooth(method="loess") +
scale_size_area()
see1 = filter(mutate(ABT,ratio =mortage_total_bal/GDP,ratio2 = mortgage_bal/GDP,ratio3 = mortgage_bal/md_total),is.na(ratio)==FALSE)
ABT = left_join (GDP1,Bank_ABT_M,by="time")
ABT = left_join (ABT,mutate(select(Cl_info_total,data_dt,mortgage_cnt,mortgage_bal),time=as.POSIXct(data_dt)),by="time")
Cl_info_part5 = summarise(Cl_info_part4,mortage_total_cnt=n_distinct())
Cl_info_part5 = summarise(Cl_info_part4,mortage_total_cnt=n_distinct(bank_name))
View(Cl_info_part4)
View(Cl_info_part3)
Cl_info_part5 = summarise(Cl_info_part3,
mortage_total_bal = sum(mortgage_bal, na.rm = TRUE),
mortage_total_cnt=n_distinct(bank_nm)
)
t1_1 = left_join(GDP_part6,Cl_info_part5,by="time")
t2_1 = filter(t1_1,is.na(mortage_total_bal)==FALSE)
see1 = filter(mutate(t2_1,ratio =mortage_total_bal/GDP),is.na(ratio)==FALSE)
ggplot(see1, aes(time, ratio)) +
geom_point(aes(size = mortage_total_cnt), alpha = 1/2) +
geom_smooth(method="loess") +
scale_size_area()
see1_1 = filter(mutate(t2_1,ratio =mortage_total_bal/GDP),is.na(ratio)==FALSE)
write.table(see1_1,file="/Volumes/AhaStorage/TEMP/RETL_Fig.dat",sep=",",row.names=F,col.names=F)
write.table(see1_1,file="/Volumes/AhaStorage/TEMP/RETL_Fig.csv",sep=",",row.names=F,col.names=F)
library(slidify)
author(deckdir="Volumes/AhaStorage/Project/R",use_git=FALSE,open_rmd=FALSE)
library(DSC2014Tutorial)
ETL_file('cl_info_other.csv')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
ETL_file('cl_info_other.csv')
a = ETL_file('cl_info_other.csv')
library(DSC2014Tutorial)
Cl_info = read.table(file=ETL_file('cl_info_other.csv'),header=T,sep=",",stringsAsFactors=F)
View(Cl_info)
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
library(dplyr)
Cl_info = read.table(file='/Volumes/AhaStorage/A_Project/R_ETL/data/cl_info_other.csv',header=T,sep=",",stringsAsFactors=F)
Cl_info_part = select(Cl_info,data_dt,bank_nm,mortgage_bal)
#Cl_info_part2 = filter(Cl_info,mortgage_bal>1000000)
#Cl_info_part3 = filter(Cl_info,mortage = mortgage/1000000)
#Cl_info_part4 = arrange(Cl_info,mortage,desc(data_dt))
Cl_info_part2 = mutate(Cl_info_part,time= as.POSIXct(data_dt)) #已看過
Cl_info_part3 = group_by(Cl_info_part2,time) #先匯總
Cl_info_part4 = summarise(Cl_info_part3,
mortage_total_bal = sum(mortgage_bal, na.rm = TRUE))
GDP = read.table(file='/Volumes/AhaStorage/A_Project/R_ETL/data/GDP.txt',sep=",",stringsAsFactors=F,header=F)
#GDP_part1 = cbind(GDP,y=1:154)
#GDP_part2 = filter(GDP_part1,y>4&y<137)
GDP_part1 = GDP[5:136,]
colnames(GDP_part1) = c("time","GDP","GDP_yoy"
,"GDP_2006","GDP_2006_yoy",
"GDP_minus","GDP_minus_yoy")
GDP_part2= mutate(GDP_part1,GDP = as.numeric(gsub(",", "",GDP))*1000000)
GDP_part3 = mutate(GDP_part2,year=as.numeric(substr(time,0,4)),season=as.numeric(substr(time,6,6)))
GDP_part4 = select(GDP_part3,year,season,GDP)
GDP_part5 = filter(summarise(group_by(GDP_part4,year),GDP=sum(GDP)),is.na(GDP)==FALSE)
x=data.frame(c1 = c(1,1,2,3,4,5,5),c2 = c('A','B','C','D','E','F','G'))
y=data.frame(c1 = c(1,2,2,3,4,6,6),c2 = c('A','B','C','D','E','F','G'))
ljxy = left_join(x,y,by="c1")
ljyx = left_join(y,x,by="c1")
GDP_part6 = select(mutate(GDP_part5 , time = as.POSIXct(paste(year,'1','1',sep='-'))),time,GDP)
t1 = left_join(GDP_part6,Cl_info_part4,by="time")
t2 = filter(t1,is.na(mortage_total_bal)==FALSE)
see1 = filter(mutate(t2,ratio =mortage_total_bal/GDP),is.na(ratio)==FALSE)
see1 = filter(mutate(t2,ratio =mortage_total_bal/GDP),is.na(ratio)==FALSE)
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
library(slidify)
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
detach("package:slidify", unload=TRUE)
library("slidify", lib.loc="~/Library/R/3.1/library")
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
x=data.frame(c1 = c(1,1,2,3,4,5,5),c2 = c('A','B','C','D','E','F','G'))
y=data.frame(c1 = c(1,2,2,3,4,6,6),c2 = c('A','B','C','D','E','F','G'))
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
library("slidifyLibraries", lib.loc="~/Library/R/3.1/library")
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
library(ggplot2)
ggplot(see1, aes(time, ratio))+geom_smooth(method="loess") +
scale_size_area() +geom_point(aes(size = 20), alpha = 1/2)
inneryx = inner_join(y,x,by="c1")
x=data.frame(c1 = c(1,1,2,3,4,5,5),c2 = c('A','B','C','D','E','F','G'))
y=data.frame(c1 = c(1,2,2,3,4,6,6),c2 = c('A','B','C','D','E','F','G'))
inneryx = inner_join(y,x,by="c1")
```{r}
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')
slidify("index.Rmd");publish(user = "ntuaha", repo = "R_ETL_LAB", host = 'github')