-
Notifications
You must be signed in to change notification settings - Fork 9
/
Testing efficiency of coding.Rmd
70 lines (46 loc) · 3.47 KB
/
Testing efficiency of coding.Rmd
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
---
title: "Testing efficiency of coding"
author: "Ryo®, Eng Lian Hu"
date: "8/28/2015"
output:
html_document:
fig_height: 3
fig_width: 5
highlight: haddock
theme: cerulean
toc: yes
---
This is an casting page of testing the efficiency of the coding for the research on `Betting Strategy and Model Validation`
```{r load-packages}
## Loading the packages
if(!'devtools' %in% installed.packages()){
install.packages('devtools')}
if(!'BBmisc' %in% installed.packages()){
install.packages('BBmisc')}
suppressPackageStartupMessages(library('BBmisc'))
pkgs <- c('devtools','RStudioAMI','zoo','chron','stringr','stringi','reshape','reshape2','data.table','sparkline','DT','plyr','dplyr','magrittr','parallel','foreach','memoise','manipulate','ggplot2','ggthemes','proto','extrafont','directlabels','PerformanceAnalytics','plotly','doMC','doParallel','BiocParallel','rvest','RSelenium','highlightHTML','knitr','rmarkdown','editR','scales','lubridate','tidyr','whisker','gtable','grid','gridExtra')
suppressAll(lib(pkgs)); rm(pkgs)
```
```{r get-data-summary-table-2.1}
nrow(do.call(rbind, llply(as.list(seq(2011,2015)), function(x) data.frame(Sess=x,read.csv(paste0(getwd(),'/datasets/',x,'.csv'))),.parallel=TRUE)))
nrow(rbind_all(llply(as.list(seq(2011,2015)), function(x) data.frame(Sess=x,read.csv(paste0(getwd(),'/datasets/',x,'.csv'))),.parallel=TRUE)))
system.time(do.call(rbind, llply(as.list(seq(2011,2015)), function(x) data.frame(Sess=x,read.csv(paste0(getwd(),'/datasets/',x,'.csv'))),.parallel=TRUE)))
system.time(rbind_all(llply(as.list(seq(2011,2015)), function(x) data.frame(Sess=x,read.csv(paste0(getwd(),'/datasets/',x,'.csv'))),.parallel=TRUE)))
```
You can also embed plots, for example:
```{r merge_all-dataframes-2.2}
#'@ system.time(Reduce(function(x,y) {merge(x,y,all=TRUE)}, llply(list(df1,df1.sps,df1.pst),function(x) x[[1]])))
#'@ system.time(merge_all(list(df1[[1]],df1.sps[[1]],df1.pst[[1]])))
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
```{r}
#'@ system.time(merge(socData, othData, all=TRUE))
#'@ system.time(merge_all(list(socData, othData)))
```
From the research, I learned from some articles which compare the efficiency of data measurement which will apply in future data analyse and data mining etc.
- [Comparing performance of by, ddply and data.table](http://www.r-bloggers.com/transforming-subsets-of-data-in-r-with-by-ddply-and-data-table/)
- [R高性能包介绍与并行运算](https://mp.weixin.qq.com/s?__biz=MzA3NDUxMjYzMA%3D%3D&mid=216065319&idx=1&sn=31af52816c7e8b937f15480c4d5f6e41&key=0acd51d81cb052bcbc420864d8003491eba2f4bbc722bf3a7bc7da0d59fefc64ea6fc32bdb33673eebd62f201cbc2190&ascene=7&uin=MjAwMTM4MjU0OA%3D%3D&devicetype=android-19&version=26020236&nettype=WIFI&pass_ticket=GdViEIR%2F5PLzVFnzLxc71K39ze4fb6VAwvFp1bhH3inbu5xBjyQ7BLEpDOrQhWZ1)
- [A biased comparsion of JSON packages in R](https://rstudio-pubs-static.s3.amazonaws.com/31702_9c22e3d1a0c44968a4a1f9656f1800ab.html)
- [Video how-to: Speed up R with C++ and Rcpp](http://www.computerworld.com/article/2961056/data-analytics/video-how-to-speed-up-r-with-c-plus-plus-and-rcpp-package.html)
- [benchmarking logistic regression using glm.fit , bigglm, speedglm, glmnet, LiblineaR](http://stackoverflow.com/questions/19532651/benchmarking-logistic-regression-using-glm-fit-bigglm-speedglm-glmnet-libli)
- [Dates and Times Made Easy with lubridate](http://www.jstatsoft.org/article/view/v040i03/v40i03.pdf)