-
Notifications
You must be signed in to change notification settings - Fork 1
/
R1.html
880 lines (397 loc) · 52.9 KB
/
R1.html
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
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
<!DOCTYPE html>
<html class="theme-next pisces use-motion" lang="en">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />
<link href="/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />
<meta name="keywords" content="R" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.2" />
<meta name="description" content="R instructions and projects for beginners">
<meta property="og:type" content="article">
<meta property="og:title" content="R - catch and analyze info on Website ">
<meta property="og:url" content="sharonjxr.github.io/R1.html">
<meta property="og:site_name" content="Creative Mix">
<meta property="og:description" content="R instructions and projects for beginners">
<meta property="og:image" content="sharonjxr.github.io/images/13.jpg">
<meta property="og:image" content="sharonjxr.github.io/images/15.JPG">
<meta property="og:updated_time" content="2018-08-23T19:44:40.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="R - catch and analyze info on Website ">
<meta name="twitter:description" content="R instructions and projects for beginners">
<meta name="twitter:image" content="sharonjxr.github.io/images/13.jpg">
<script type="text/javascript" id="hexo.configurations">
var NexT = window.NexT || {};
var CONFIG = {
root: '/',
scheme: 'Pisces',
version: '5.1.2',
sidebar: {"position":"left","display":"post","offset":12,"offset_float":12,"b2t":false,"scrollpercent":false,"onmobile":false},
fancybox: true,
tabs: true,
motion: true,
duoshuo: {
userId: '0',
author: 'Author'
},
algolia: {
applicationID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
}
};
</script>
<link rel="canonical" href="sharonjxr.github.io/R1.html"/>
<title>R - catch and analyze info on Website | Creative Mix</title>
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="en">
<div class="container sidebar-position-left page-post-detail ">
<div class="headband"></div>
<header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-wrapper">
<div class="site-meta ">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Creative Mix</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<p class="site-subtitle">Home for Xuerong Jia's Git repositories</p>
</div>
<div class="site-nav-toggle">
<button>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section">
<i class="menu-item-icon fa fa-fw fa-home"></i> <br />
Home
</a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories/" rel="section">
<i class="menu-item-icon fa fa-fw fa-th"></i> <br />
Categories
</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section">
<i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
Archives
</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags/" rel="section">
<i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
Tags
</a>
</li>
</ul>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<div id="posts" class="posts-expand">
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="sharonjxr.github.io/R1.html">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Xuerong Jia">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Creative Mix">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">R - catch and analyze info on Website </h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Post created" itemprop="dateCreated datePublished" datetime="2017-09-09T15:23:40-07:00">
2017-09-09
</time>
</span>
<span class="post-category" >
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">In</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/Data-Analytics/" itemprop="url" rel="index">
<span itemprop="name">Data Analytics</span>
</a>
</span>
,
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/Data-Analytics/R-Programming/" itemprop="url" rel="index">
<span itemprop="name">R Programming</span>
</a>
</span>
</span>
<div class="post-description">
R instructions and projects for beginners
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<div class="post-gallery" itemscope itemtype="http://schema.org/ImageGallery">
<div class="post-gallery-row">
<a class="post-gallery-img fancybox"
href="/images/13.jpg" rel="gallery_cjlg02chx0008mwvd65k2c0j1"
itemscope itemtype="http://schema.org/ImageObject" itemprop="url">
<img src="/images/13.jpg" itemprop="contentUrl"/>
</a>
<a class="post-gallery-img fancybox"
href="/images/15.JPG" rel="gallery_cjlg02chx0008mwvd65k2c0j1"
itemscope itemtype="http://schema.org/ImageObject" itemprop="url">
<img src="/images/15.JPG" itemprop="contentUrl"/>
</a>
</div>
</div>
<h1 id="R-Programming-for-beginners"><a href="#R-Programming-for-beginners" class="headerlink" title="R Programming for beginners"></a>R Programming for beginners</h1><p>File - new R Script<br>comments: #</p>
<h2 id="Create-a-value-vector"><a href="#Create-a-value-vector" class="headerlink" title="Create a value/vector"></a>Create a value/vector</h2><figure class="highlight r"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line"><span class="number">1</span>+<span class="number">1</span> => [<span class="number">1</span>] <span class="number">2</span></div><div class="line"></div><div class="line">x = <span class="number">1</span> + <span class="number">1</span> ; </div><div class="line"></div><div class="line">=> [<span class="number">1</span>] <span class="number">2</span></div><div class="line"></div><div class="line">x = <span class="number">1</span> + <span class="number">1</span> => nothing</div><div class="line"></div><div class="line">grades = c(<span class="number">100</span>,<span class="number">90</span>,<span class="number">85</span>,<span class="number">95</span>); grades => [<span class="number">1</span>] (<span class="number">100</span>,<span class="number">90</span>,<span class="number">85</span>,<span class="number">95</span>)</div><div class="line">grades + <span class="number">5</span>=></div><div class="line"></div><div class="line"> - <span class="keyword">function</span>: class(X) => data types ofunction X(Numeric/Character)</div><div class="line"></div><div class="line"> - y = c(<span class="number">5</span>,<span class="number">10</span>,<span class="string">"15"</span>,<span class="number">20</span>) ; y is not numerial anymore though only one element is char, now y is chr and change into [<span class="number">1</span>]<span class="string">"5"</span>,<span class="string">"10"</span>,<span class="string">"15"</span>,<span class="string">"20"</span></div><div class="line"> - <span class="keyword">function</span>: char to numeric: y = as.numeric(y) => [<span class="number">1</span>] <span class="number">5</span> <span class="number">10</span> <span class="number">15</span> <span class="number">20</span></div><div class="line"> - <span class="keyword">function</span>: numeric to char as.character</div><div class="line"></div><div class="line"> - Trouble <span class="number">1</span>: run previous results neccessary; solution: <span class="comment">#comments the variable</span></div><div class="line"> - Trouble <span class="number">2</span>: select rows <span class="keyword">in</span> code=> run only what you want</div></pre></td></tr></table></figure>
<figure class="highlight r"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line"></div><div class="line"><span class="keyword">function</span> table()& summarize() to calculate the frequency of Vector/Matrix</div><div class="line"></div><div class="line">Print some positions of V: </div><div class="line">Print some positions of V: </div><div class="line">V[<span class="number">1</span>,<span class="number">2</span>] correct into V[c(<span class="number">1</span>,<span class="number">2</span>)]</div><div class="line">V[-<span class="number">2</span>] is OK,but not V[-<span class="number">1</span>,-<span class="number">2</span>], it prints positions except positon <span class="number">2</span></div><div class="line"></div><div class="line"><span class="keyword">function</span> sequence: <span class="number">1</span>:<span class="number">10</span>; seq(<span class="number">1</span>,<span class="number">10</span>);seq(to = <span class="number">10</span>, from = <span class="number">1</span>);seq(<span class="number">10</span>,<span class="number">1</span>);seq(from = <span class="number">1</span>, to = <span class="number">10</span>, by = +-<span class="number">2</span>)</div><div class="line"></div><div class="line"><span class="keyword">function</span> <span class="keyword">repeat</span>: rep(<span class="string">"HI"</span>,<span class="number">10</span>)</div><div class="line"> // will not interfere with embedded <a href=<span class="string">"#voila2"</span>>tags</a>.</div><div class="line"> </div><div class="line"><span class="literal">NA</span> means sth does not exist</div><div class="line"></div><div class="line"><span class="keyword">function</span> 把一大组数归纳总结频率table(),转成表as.data.frame(table()),在表里加一些colomn比如Order:cbind.data.frame</div><div class="line"></div><div class="line"><span class="keyword">function</span> 排序 order()升序,order(-)降序</div><div class="line"></div><div class="line"> - Remember <span class="number">4</span>: Vector[c(<span class="number">1</span>,<span class="number">2</span>,<span class="number">3.</span>..)]获取数值,而matrix$..来获取! 注意!</div><div class="line"> - Remember <span class="number">5</span>: Vector直接 mean(Vector)就好!</div><div class="line"> - Remember <span class="number">1</span>: Variable[<span class="number">1</span>] not V[<span class="number">0</span>] prints the first one</div><div class="line"> - Remember <span class="number">2</span>: Variable<span class="string">'s name should be combined without space between</span></div><div class="line"> - Remember 3: Factors can not be allowed to compare value (=<>)</div></pre></td></tr></table></figure>
<h2 id="Metrix"><a href="#Metrix" class="headerlink" title="Metrix:"></a>Metrix:</h2><figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">function data.frame(v1,v2) , if length ofunction v1 is larger than v2 then v2's vector in metrix will be repeated to fill the space.</div><div class="line"></div><div class="line">add another colomn to metrix: function cbind(data.frame(v1,v2), v3)</div><div class="line">1. 先按照要求造个vector,再作为一个colomn加上去!!!!</div><div class="line"></div><div class="line">function colnames/rownames(M) = c("","") to change the names</div><div class="line"></div><div class="line">function M[A,B] Row 1st, colomn 2nd show numbr on that position, A or B can be left empty to show the full colomn/row, B can be 1:2 or c(1,2) both OK!</div><div class="line"></div><div class="line">function: View(metrix) -> show the table </div><div class="line"></div><div class="line">function length, nrow, ncol, head() tail() names() #head rows, </div><div class="line"></div><div class="line">Sum Fuction: sum(data[,5]); sum(data$population)</div><div class="line"></div><div class="line"> - function 不是countif和count,是nrow()! : X[X$region==1,] Return all information on states located in only 1(region ==1). nrow()to count . </div><div class="line">Add conditions on colomn show only colomn: X[X$region==1,".."or 1 ]</div><div class="line"></div><div class="line"> - function data[data$murder==max(data$murder), "state"] return the state ofunction largest murder</div><div class="line"> </div><div class="line">function: T/function matrix: data[data$murder, 1]==max(data$murder) not data[data$murder==max(data$murder), ]</div><div class="line"></div><div class="line">function:ifelse()ifelse(data$illiteracy<1, "low","high")</div><div class="line"></div><div class="line">function 提取table的字/标题 names(table), 提取table的数字 numeric(table)</div></pre></td></tr></table></figure>
<h2 id="FOR-LOOP-提取colomn-创建结果为colomn(各个添加)"><a href="#FOR-LOOP-提取colomn-创建结果为colomn(各个添加)" class="headerlink" title="FOR LOOP + 提取colomn + 创建结果为colomn(各个添加)"></a>FOR LOOP + 提取colomn + 创建结果为colomn(各个添加)</h2><figure class="highlight r"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">Create a new column “Age.Range” </div><div class="line">age = hw1$Age</div><div class="line">Age.Range = <span class="string">""</span></div><div class="line"><span class="keyword">for</span>( i <span class="keyword">in</span> <span class="number">1</span>:length(age)){<span class="keyword">if</span> (age[i] < <span class="number">20</span>){Age.Range[i]=<span class="string">"Below 20 years"</span>} <span class="keyword">else</span> <span class="keyword">if</span>(<span class="number">25</span>> age[i]){Age.Range[i] = <span class="string">"[20-25) years"</span>}<span class="keyword">else</span> <span class="keyword">if</span>(<span class="number">30</span> > age[i]){Age.Range[i] = <span class="string">"[25-30) years"</span>} </div><div class="line"><span class="keyword">else</span> <span class="keyword">if</span>(<span class="number">30</span>< age[i]){Age.Range[i] = <span class="string">"Above 30 years"</span>}}</div><div class="line">Age.Range</div></pre></td></tr></table></figure>
<h2 id="import-outside-data-source"><a href="#import-outside-data-source" class="headerlink" title="import outside data source"></a>import outside data source</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">change/get working directory</div><div class="line">function getwd(); setwd(<span class="string">"D:/AW/MSBA&Programming合集/R"</span>); </div><div class="line"></div><div class="line">open <span class="keyword">and</span> save file: function data= read.csv(<span class="string">"statedata.csv"</span>)];</div><div class="line">{% endcodeblock %}</div></pre></td></tr></table></figure>
<h2 id="CODES"><a href="#CODES" class="headerlink" title="CODES"></a>CODES</h2><figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div></pre></td><td class="code"><pre><div class="line">{% codeblock lang:R %}</div><div class="line">[</div><div class="line"></div><div class="line">x = 1+1</div><div class="line">#x</div><div class="line"></div><div class="line"> </div><div class="line">grades = c(100,90, 85, 95)</div><div class="line"># grades</div><div class="line"></div><div class="line">classes = c("DS", "ss")</div><div class="line"># classes</div><div class="line"></div><div class="line">class(classes)</div><div class="line"></div><div class="line">grades + 5</div><div class="line"></div><div class="line">y = c(5,10,"15",20)</div><div class="line">y = as.numeric(y)</div><div class="line">#y</div><div class="line"></div><div class="line">#y[1]</div><div class="line"></div><div class="line">#grades[c(1,2,4)]</div><div class="line"></div><div class="line">#grades[-3,-4]</div><div class="line"></div><div class="line">Metrix1 = cbind(data.frame(y,classes),grades)</div><div class="line">#View(Metrix1)</div><div class="line"></div><div class="line"></div><div class="line">rownames(Metrix1) = c("stu1","stu2","stu3","stu4")</div><div class="line">View(Metrix1)</div><div class="line"></div><div class="line">nrow(Metrix1)</div><div class="line"></div><div class="line">2:10</div><div class="line">seq(1,10)</div><div class="line">seq(to = 10, from = 1)</div><div class="line">seq(10,1) </div><div class="line">seq(from = 1, to = 10, by = 2)</div><div class="line"></div><div class="line">rep("HI",10)</div><div class="line"></div><div class="line">data= read.csv("statedata.csv")</div><div class="line">View(data)</div><div class="line"></div><div class="line">tail(data)</div><div class="line"></div><div class="line">sum(data[,5])</div><div class="line"></div><div class="line">sum(data$population)</div><div class="line"></div><div class="line">nrow(data[data$region== 1 ,])</div><div class="line"></div><div class="line">data[data$illiteracy<0.7, "state"]</div><div class="line"></div><div class="line"></div><div class="line">#data[data$murder==max(data$murder) or data$murder==min(data$murder), "state" ]</div><div class="line"></div><div class="line">data[data$murder==max(data$murder) and data$murder==min(data$murder) ,1]</div><div class="line"></div><div class="line">data[data$murder, 1]==max(data$murder)</div><div class="line"></div><div class="line">data$illiteracyCategory = ifelse(data$illiteracy<1, "low","high")</div><div class="line"></div><div class="line">data[data$illiteracyCategory=="low",] ];</div><div class="line"></div><div class="line">{% endcodeblock %}</div></pre></td></tr></table></figure>
<h2 id="conditional-Loops-in-R-—-Stupid-guy"><a href="#conditional-Loops-in-R-—-Stupid-guy" class="headerlink" title="conditional Loops in R — Stupid guy"></a>conditional Loops in R — Stupid guy</h2><p>Age.Range = if(hw1$Age < 20){“Below 20 years”} else{<br> if(25> hw1$Age >= 20){“[20-25) years”}<br> else{<br> if(30 > hw1$Age >= 25){“[25-30) years”}<br> else{“Above 30 years”}}}<br>错了!为啥???</p>
<ol>
<li>因为elseif 应该是 else if </li>
<li>else if 最后一项也是,不能是else 要写清条件</li>
</ol>
<h2 id="R-Analysis-for-most-popular-clothes-On-Stylenanda-Shop"><a href="#R-Analysis-for-most-popular-clothes-On-Stylenanda-Shop" class="headerlink" title="R Analysis for most popular clothes On Stylenanda Shop"></a>R Analysis for most popular clothes On Stylenanda Shop</h2><h3 id="Beginning"><a href="#Beginning" class="headerlink" title="Beginning"></a>Beginning</h3><p> So today we gonna come through some simple data analysis to find the most popular clothes ofunction famous brand “Stylenanda”. (Data from <a href="http://en.stylenanda.com/" target="_blank" rel="external">http://en.stylenanda.com/</a>)</p>
<h3 id="Step-1-catch-info"><a href="#Step-1-catch-info" class="headerlink" title="Step 1: catch info"></a>Step 1: catch info</h3><p>All the informations we need are the name price, sales and comments ofunction all the clothes.</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">Library(rvest)</div><div class="line">Library(xml2)</div><div class="line">> <span class="keyword">as</span><-seq(<span class="number">60</span>,<span class="number">420</span>,<span class="number">60</span>) </div><div class="line">> <span class="keyword">for</span>(s <span class="keyword">in</span> <span class="keyword">as</span>){ </div><div class="line">moda<-read_html(<span class="string">"Stylenandas=60&q=%C1%AC%D2%C2%C8%B9&sort=s&style=g&from=sn_1_brand-qp&active=2&industryCatId=50025135&type=pc#J_Filter"</span>,encoding=<span class="string">"GBK"</span>) +dress_name<-html_nodes(moda,<span class="string">'.productTitle a'</span>)%>%html_text</div><div class="line">dress_name<-html_nodes(stylenanda,<span class="string">'.productTitle a'</span>)%>%html_text </div><div class="line">dress_price<-html_nodes(stylenanda,<span class="string">'.productPrice em'</span>)%>%html_text sale_number<-html_nodes(stylenanda,<span class="string">'.productStatus em'</span>)%>%html_text</div><div class="line">> the_comment<-html_nodes(stylenanda,<span class="string">'.productStatus a'</span>)%>%html_text </div><div class="line"></div><div class="line">+ }</div><div class="line">> dress<-data.frame(dressname,dressprice,salenumber,thecomment)</div></pre></td></tr></table></figure>
<h3 id="Step-2-Integrate-and-Standardize-our-data"><a href="#Step-2-Integrate-and-Standardize-our-data" class="headerlink" title="Step 2: Integrate and Standardize our data"></a>Step 2: Integrate and Standardize our data</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">> library(plyr) </div><div class="line">> Unify variable name</div><div class="line">dress1<rename(dress1,c(dress_name=<span class="string">"dressname"</span>,dress_price=<span class="string">"dressprice"</span>,sale_number=<span class="string">"salenumber"</span>,the_comment=<span class="string">"thecomment"</span>) </div><div class="line">> Modadress <-rbind(dress,dress1)</div></pre></td></tr></table></figure>
<p>We got the output for “Modadress$dressprice” , new column for the dress price</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">[<span class="number">1</span>] ¥<span class="number">399.00</span> ¥<span class="number">299.50</span> ¥<span class="number">749.00</span> ¥<span class="number">699.00</span> ¥<span class="number">112.00</span> ¥<span class="number">306.00</span> ¥<span class="number">298.00</span> ¥<span class="number">649.00</span></div><div class="line"> [<span class="number">9</span>] ¥<span class="number">299.00</span> ¥<span class="number">279.00</span> ¥<span class="number">249.00</span> ¥<span class="number">299.50</span> ¥<span class="number">374.50</span> ¥<span class="number">324.50</span> ¥<span class="number">274.50</span> ¥<span class="number">324.50</span></div><div class="line"> [<span class="number">17</span>] ¥<span class="number">349.50</span> ¥<span class="number">199.00</span> ¥<span class="number">349.50</span> ¥<span class="number">699.00</span> ¥<span class="number">279.00</span> ¥<span class="number">349.00</span> ¥<span class="number">749.00</span> ¥<span class="number">199.00</span></div><div class="line"> [<span class="number">25</span>] ¥<span class="number">299.50</span> ¥<span class="number">324.50</span> ¥<span class="number">349.50</span> ¥<span class="number">349.50</span> ¥<span class="number">349.50</span> ¥<span class="number">324.50</span> ¥<span class="number">324.50</span> ¥<span class="number">299.0</span></div></pre></td></tr></table></figure>
<p>The number ofunction dress sales :</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">[<span class="number">1</span>] <span class="number">1198</span>笔 <span class="number">1394</span>笔 <span class="number">0</span>笔 <span class="number">0</span>笔 <span class="number">1</span>笔 <span class="number">0</span>笔 <span class="number">1934</span>笔 <span class="number">64</span>笔 <span class="number">836</span>笔 <span class="number">1848</span>笔 <span class="number">1203</span>笔</div><div class="line"> [<span class="number">12</span>] <span class="number">566</span>笔 <span class="number">573</span>笔 <span class="number">1380</span>笔 <span class="number">1808</span>笔 <span class="number">609</span>笔 <span class="number">1776</span>笔 <span class="number">1621</span>笔 <span class="number">1162</span>笔 <span class="number">348</span>笔 <span class="number">470</span>笔 <span class="number">397</span>笔 </div><div class="line"> [<span class="number">23</span>] <span class="number">446</span>笔 <span class="number">364</span>笔 <span class="number">468</span>笔 <span class="number">579</span>笔 <span class="number">666</span>笔 <span class="number">362</span>笔 <span class="number">776</span>笔 <span class="number">770</span>笔 <span class="number">617</span>笔 <span class="number">611</span>笔 <span class="number">791</span>笔 </div><div class="line"> [<span class="number">34</span>] <span class="number">154</span>笔 <span class="number">781</span>笔 <span class="number">275</span>笔 <span class="number">1118</span>笔 <span class="number">688</span>笔 <span class="number">916</span>笔 <span class="number">772</span>笔 <span class="number">569</span>笔 <span class="number">55</span>笔 <span class="number">114</span>笔 <span class="number">927</span>笔 </div><div class="line"> [<span class="number">45</span>] <span class="number">471</span>笔 <span class="number">750</span>笔 <span class="number">1117</span>笔 <span class="number">734</span>笔 <span class="number">798</span>笔 <span class="number">208</span>笔 <span class="number">620</span>笔 <span class="number">492</span>笔 <span class="number">298</span>笔 <span class="number">160</span>笔 <span class="number">846</span>笔 </div><div class="line"> [<span class="number">56</span>] <span class="number">902</span>笔 <span class="number">109</span>笔 <span class="number">345</span>笔 <span class="number">802</span>笔 <span class="number">101</span>笔 <span class="number">688</span>笔 <span class="number">912</span>笔 <span class="number">774</span>笔 <span class="number">569</span>笔 <span class="number">55</span>笔 <span class="number">115</span>笔</div></pre></td></tr></table></figure>
<p>Then we need to filter and delete the unnecessary info </p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">Modadress$dressprice<-gsub(<span class="string">"¥"</span>,<span class="string">""</span>,Modadress$dressprice)</div><div class="line">Modadress$salenumber<-gsub(<span class="string">"笔"</span>,<span class="string">""</span>,Modadress$salenumber)</div></pre></td></tr></table></figure>
<p>Find their properties</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">> class(modadress$salenumber)</div><div class="line">[1] "factor"</div><div class="line">>class(modadress$thecomment)</div><div class="line">[1] "factor" </div><div class="line">> class(dressprice) </div><div class="line">[1] "character"</div></pre></td></tr></table></figure>
<p>Change strings into number format:</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">> Modadress$dressprice<-<span class="keyword">as</span>.numeric(modadress$dressprice) </div><div class="line">> Modadress$salenumber<-<span class="keyword">as</span>.numeric(modadress$salenumber)</div><div class="line">> Modadress$thecomment<-<span class="keyword">as</span>.numeric(modadress$thecomment)</div></pre></td></tr></table></figure>
<h3 id="Step3-Summarize-and-Visualize-data"><a href="#Step3-Summarize-and-Visualize-data" class="headerlink" title="Step3: Summarize and Visualize data"></a>Step3: Summarize and Visualize data</h3><p>Summarize data:</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">group_by(Modadress,priceleve)%>%summarise(price=mean(dressprice,na.rm=T),number=mean(salenumber,na.rm=T),comment=mean(thecomment,na.rm=T))</div><div class="line"><span class="comment"># A tibble: 2 x 4</span></div><div class="line"> priceleve price number comment</div><div class="line"> <fctr> <dbl> <dbl> <dbl></div><div class="line"><span class="number">1</span> high <span class="number">722.5484</span> <span class="number">117.6774</span> <span class="number">39.90323</span></div><div class="line"><span class="number">2</span> normal <span class="number">316.2674</span> <span class="number">703.0562</span> <span class="number">422.12360</span></div></pre></td></tr></table></figure>
<p>Visualize data in chart</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ggplot(Modadress,aes(x=dressprice,y=salenumber,color=thecomment))+geom_point()+scale_x_continuous(expand=c(<span class="number">0</span>,<span class="number">0</span>),breaks=c(<span class="number">100</span>,<span class="number">200</span>,<span class="number">300</span>,<span class="number">400</span>,<span class="number">500</span>,<span class="number">600</span>,<span class="number">700</span>,<span class="number">800</span>,<span class="number">900</span>,<span class="number">1000</span>,<span class="number">1100</span>),labels=c(<span class="number">100</span>,<span class="number">200</span>,<span class="number">300</span>,<span class="number">400</span>,<span class="number">500</span>,<span class="number">600</span>,<span class="number">700</span>,<span class="number">800</span>,<span class="number">900</span>,<span class="number">1000</span>,<span class="number">1100</span>))</div></pre></td></tr></table></figure>
<p><img src="images/13.jpg" width="500"></p>
<p>From the picture, a lot ofunction clothes fall into the range ofunction 200RMB-400RMB, fewer cost more than 650RMB and none cost 400RMB-650RMB.</p>
<p>Then in order to figure out the sales ofunction clothes falling into each range, we need to recode the price at first and add “pricelevel” variable after that. </p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">Modadress<-within(Modadres,{</div><div class="line">pricelevel<-<span class="string">"NA"</span></div><div class="line">pricelevel[dressprice<<span class="number">450</span>]<-<span class="string">"normal"</span></div><div class="line">pricelevel[dressprice><span class="number">500</span>]<-<span class="string">"high"</span></div><div class="line">})</div></pre></td></tr></table></figure>
<p>Calculate the sales ofunction clothes falling into each range.</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">total<-tapply(Modadress$salenumber,Modadress$pricelevel,sum)</div><div class="line">> total</div><div class="line"> high normal </div><div class="line"> <span class="number">3648</span> <span class="number">62572</span></div></pre></td></tr></table></figure>
<p>Differences between two levels ofunction sales are obvious. Now we shall draw into picture to show clearly.</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">z<-c(<span class="string">"high"</span>,<span class="string">"normal"</span>)</div><div class="line">chart<-data.frame(z,total)</div><div class="line">> wtp<-ggplot(chart,aes(x=z,y=total))+geom_bar(stat=<span class="string">"identity"</span>,fill=<span class="string">"lightblue"</span>,width=<span class="number">0.5</span>)+geom_text(aes(label=total),vjust=<span class="number">-0.2</span>,colour=<span class="string">"black"</span>,size=<span class="number">8</span>)</div><div class="line">> wtp+xlab(<span class="string">"price"</span>)+ylab(<span class="string">"sales"</span>)</div></pre></td></tr></table></figure>
<p><img src="images/14.jpg" width="500"></p>
<h3 id="Step-4-Get-the-data-we-what-and-rule-out-others"><a href="#Step-4-Get-the-data-we-what-and-rule-out-others" class="headerlink" title="Step 4: Get the data we what and rule out others"></a>Step 4: Get the data we what and rule out others</h3><p>At first we need to specify the meaning ofunction “Popolar clothers”. The standard I refer to is comment volume and sales volume.</p>
<p>According to the figure above, the lighter the color ofunction the blue dot, the larger the comment volume. </p>
<p>Set 1500 as dividing line and choose the best-selling products.</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">filter(Modadress,thecomment><span class="number">1500</span>)%>%arrange(desc(salenumber))</div><div class="line"> dressname dressprice salenumber thecomment priceleve</div></pre></td></tr></table></figure>
<p>Output:</p>
<p>1 Self-Tie Collar Button-Down Shirt 279 1848 1557 normal<br>2 Check Pattern Buttoned Back Shirt 199 1621 1822 normal<br>3 Pre-Damaged Knit Cardigan 249 1203 1647 normal<br>4 Extended Sleeve Lettering Print Hoodie 399 1198 2059 normal</p>
<p>Thus we got Top4 for most popular clothes:</p>
<ol>
<li><p>Self-Tie Collar Button-Down Shirt</p>
<p><img src="images/17.JPG"></p>
</li>
<li><p>Check Pattern Buttoned Back Shirt </p>
<p><img src="images/18.JPG"></p>
</li>
<li><p>Pre-Damaged Knit Cardigan </p>
<p><img src="images/19.JPG"></p>
</li>
<li><p>Extended Sleeve Lettering Print Hoodie</p>
</li>
</ol>
<p><img src="images/20.JPG"></p>
<h5 id="Come-on-Just-follow-this-instruction-and-have-a-try-Use-R-to-find-any-info-about-items-ofunction-your-favorite-brand"><a href="#Come-on-Just-follow-this-instruction-and-have-a-try-Use-R-to-find-any-info-about-items-ofunction-your-favorite-brand" class="headerlink" title="Come on! Just follow this instruction and have a try. Use R to find any info about items ofunction your favorite brand."></a>Come on! Just follow this instruction and have a try. Use R to find any info about items ofunction your favorite brand.</h5>
</div>
<footer class="post-footer">
<div class="post-tags">
<a href="/tags/Demo/" rel="tag"># Demo</a>
<a href="/tags/R-Programming/" rel="tag"># R Programming</a>
<a href="/tags/data-analysis/" rel="tag"># data analysis</a>
</div>
<div class="post-nav">
<div class="post-nav-next post-nav-item">
<a href="/Python1.html" rel="next" title="Python Demo & Code: Game Asteroids ">
<i class="fa fa-chevron-left"></i> Python Demo & Code: Game Asteroids
</a>
</div>
<span class="post-nav-divider"></span>
<div class="post-nav-prev post-nav-item">
<a href="/JAVA1.html" rel="prev" title="Java Web: Online Shop Project">
Java Web: Online Shop Project <i class="fa fa-chevron-right"></i>
</a>
</div>
</div>
</footer>
</div>
</article>
<div class="post-spread">
</div>
</div>
</div>
<div class="comments" id="comments">
</div>
</div>
<div class="sidebar-toggle">
<div class="sidebar-toggle-line-wrap">
<span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
</div>
</div>
<aside id="sidebar" class="sidebar">
<div class="sidebar-inner">
<ul class="sidebar-nav motion-element">
<li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
Table of Contents
</li>
<li class="sidebar-nav-overview" data-target="site-overview">
Overview
</li>
</ul>
<section class="site-overview sidebar-panel">
<div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
<img class="site-author-image" itemprop="image"
src="/images/avatar.jpg"
alt="Xuerong Jia" />
<p class="site-author-name" itemprop="name">Xuerong Jia</p>
<p class="site-description motion-element" itemprop="description">spreading interesting ideas about coding, data analytics and instructions</p>
</div>
<nav class="site-state motion-element">
<div class="site-state-item site-state-posts">
<a href="/archives/">
<span class="site-state-item-count">8</span>
<span class="site-state-item-name">posts</span>
</a>
</div>
<div class="site-state-item site-state-categories">
<a href="/categories/index.html">
<span class="site-state-item-count">11</span>
<span class="site-state-item-name">categories</span>
</a>
</div>
<div class="site-state-item site-state-tags">
<a href="/tags/index.html">
<span class="site-state-item-count">17</span>
<span class="site-state-item-name">tags</span>
</a>
</div>
</nav>
<div class="links-of-author motion-element">
<span class="links-of-author-item">
<a href="https://github.com/sharonJXR" target="_blank" title="GitHub">
<i class="fa fa-fw fa-github"></i>
GitHub
</a>
</span>
<span class="links-of-author-item">
<a href="https://www.linkedin.com/in/XuerongJia" target="_blank" title="LinkedIn">
<i class="fa fa-fw fa-envelope"></i>
LinkedIn
</a>
</span>
</div>
</section>
<!--noindex-->
<section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
<div class="post-toc">
<div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#R-Programming-for-beginners"><span class="nav-number">1.</span> <span class="nav-text">R Programming for beginners</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#Create-a-value-vector"><span class="nav-number">1.1.</span> <span class="nav-text">Create a value/vector</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Metrix"><span class="nav-number">1.2.</span> <span class="nav-text">Metrix:</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#FOR-LOOP-提取colomn-创建结果为colomn(各个添加)"><span class="nav-number">1.3.</span> <span class="nav-text">FOR LOOP + 提取colomn + 创建结果为colomn(各个添加)</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#import-outside-data-source"><span class="nav-number">1.4.</span> <span class="nav-text">import outside data source</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#CODES"><span class="nav-number">1.5.</span> <span class="nav-text">CODES</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#conditional-Loops-in-R-—-Stupid-guy"><span class="nav-number">1.6.</span> <span class="nav-text">conditional Loops in R — Stupid guy</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#R-Analysis-for-most-popular-clothes-On-Stylenanda-Shop"><span class="nav-number">1.7.</span> <span class="nav-text">R Analysis for most popular clothes On Stylenanda Shop</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Beginning"><span class="nav-number">1.7.1.</span> <span class="nav-text">Beginning</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Step-1-catch-info"><span class="nav-number">1.7.2.</span> <span class="nav-text">Step 1: catch info</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Step-2-Integrate-and-Standardize-our-data"><span class="nav-number">1.7.3.</span> <span class="nav-text">Step 2: Integrate and Standardize our data</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Step3-Summarize-and-Visualize-data"><span class="nav-number">1.7.4.</span> <span class="nav-text">Step3: Summarize and Visualize data</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Step-4-Get-the-data-we-what-and-rule-out-others"><span class="nav-number">1.7.5.</span> <span class="nav-text">Step 4: Get the data we what and rule out others</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#Come-on-Just-follow-this-instruction-and-have-a-try-Use-R-to-find-any-info-about-items-ofunction-your-favorite-brand"><span class="nav-number">1.7.5.0.1.</span> <span class="nav-text">Come on! Just follow this instruction and have a try. Use R to find any info about items ofunction your favorite brand.</span></a></li></ol></li></ol></li></ol></li></ol></li></ol></div>
</div>
</section>
<!--/noindex-->
</div>
</aside>
</div>
</main>
<footer id="footer" class="footer">
<div class="footer-inner">
<div class="copyright" >
©
<span itemprop="copyrightYear">2018</span>
<span class="with-love">
<i class="fa fa-heart"></i>
</span>
<span class="author" itemprop="copyrightHolder">Xuerong Jia</span>
</div>
<script>
var seconds = 1000;
var minutes = seconds * 60;
var hours = minutes * 60;
var days = hours * 24;
var years = days * 365;
var birthDay = Date.UTC(2016,07,30,00,00,00); // �������ý�վʱ��
setInterval(function() {
var today = new Date();
var todayYear = today.getFullYear();
var todayMonth = today.getMonth()+1;
var todayDate = today.getDate();
var todayHour = today.getHours();
var todayMinute = today.getMinutes();
var todaySecond = today.getSeconds();
var now = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
var diff = now - birthDay;
var diffYears = Math.floor(diff/years);
var diffDays = Math.floor((diff/days)-diffYears*365);
var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
document.getElementById('showDays').innerHTML="��վ������ "+diffYears+" �� "+diffDays+" �� "+diffHours+" Сʱ "+diffMinutes+" ���� "+diffSeconds+" ��";
}, 1000);
</script>
</div>
</footer>
<div class="back-to-top">
<i class="fa fa-arrow-up"></i>
</div>
</div>
<script type="text/javascript">
if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
window.Promise = null;
}
</script>
<script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
<script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
<script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
<script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
<script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
<script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
<script type="text/javascript" src="/lib/canvas-ribbon/canvas-ribbon.js"></script>
<script type="text/javascript" src="/js/src/utils.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/motion.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/affix.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.2"></script>
</body>
</html>