├── 20160719 ├── data │ └── lottoryHistDf.RData ├── install_packages.R ├── crawl_lottery_tables.R ├── lottery_etl_viz.R ├── quantmod_ML_PCA.R ├── quantmod_ML_classification.R └── quantmod_ML_clustering.R ├── ShinyProject ├── .Rproj.user │ └── 687DFF8D │ │ ├── sdb │ │ ├── prop │ │ │ ├── 3F068418 │ │ │ ├── F517D775 │ │ │ └── INDEX │ │ └── per │ │ │ └── t │ │ │ ├── 2683FB61 │ │ │ └── F8136FCB │ │ ├── saved_source_markers │ │ └── pcs │ │ ├── source-pane.pper │ │ ├── workbench-pane.pper │ │ ├── files-pane.pper │ │ └── windowlayoutstate.pper ├── text1.csv ├── text2.csv ├── text3.csv ├── ShinyProject.Rproj ├── server.R └── ui.R ├── checkBoxFORggplot ├── .Rproj.user │ └── 687DFF8D │ │ ├── sdb │ │ └── prop │ │ │ ├── 183A62A2 │ │ │ ├── E4A887C4 │ │ │ ├── B4B9E96 │ │ │ └── INDEX │ │ ├── saved_source_markers │ │ ├── pcs │ │ ├── source-pane.pper │ │ ├── workbench-pane.pper │ │ ├── files-pane.pper │ │ └── windowlayoutstate.pper │ │ └── viewer-cache │ │ ├── 1839owj6fl.Rdata │ │ ├── a4syjw89dh.Rdata │ │ ├── by9bmdgung.Rdata │ │ └── qjvoixy435.Rdata ├── ShinyProject.Rproj ├── rsconnect │ └── shinyapps.io │ │ └── pecu │ │ └── checkBoxFORggplot.dcf ├── data.R ├── ui.R ├── server.R └── .Rhistory ├── .gitignore ├── alldata.csv ├── checkBox.zip ├── SortSample.zip ├── ProjectExample.zip ├── RSummer_20160712.pdf ├── RSummer_20160714.pdf ├── RSummer_20160711intro.pdf ├── GAtest.R ├── HelloQuantmodTest.R ├── aaplKmean.R ├── TestSVR.R ├── saveText.R ├── logisticRegression.R ├── TestSVM.R ├── HelloForLoopTest.R ├── parserPTT.R ├── SVMAAPL.R ├── textMining.R ├── onePage.R ├── parserPTTandLevels.R ├── onePageDelChar.R └── gpaData.csv /ShinyProject/.Rproj.user/687DFF8D/sdb/prop/3F068418: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /ShinyProject/.Rproj.user/687DFF8D/sdb/prop/F517D775: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /checkBoxFORggplot/.Rproj.user/687DFF8D/sdb/prop/183A62A2: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /checkBoxFORggplot/.Rproj.user/687DFF8D/sdb/prop/E4A887C4: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | -------------------------------------------------------------------------------- /alldata.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pecu/RSummer/HEAD/alldata.csv -------------------------------------------------------------------------------- /checkBox.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pecu/RSummer/HEAD/checkBox.zip -------------------------------------------------------------------------------- /SortSample.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pecu/RSummer/HEAD/SortSample.zip -------------------------------------------------------------------------------- /ShinyProject/.Rproj.user/687DFF8D/saved_source_markers: -------------------------------------------------------------------------------- 1 | {"active_set":"","sets":[]} -------------------------------------------------------------------------------- /ShinyProject/text1.csv: -------------------------------------------------------------------------------- 1 | id,value 2 | 1,10 3 | 2,20 4 | 3,30 5 | 4,40 6 | 5,50 7 | -------------------------------------------------------------------------------- /ProjectExample.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pecu/RSummer/HEAD/ProjectExample.zip -------------------------------------------------------------------------------- /RSummer_20160712.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pecu/RSummer/HEAD/RSummer_20160712.pdf -------------------------------------------------------------------------------- /RSummer_20160714.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pecu/RSummer/HEAD/RSummer_20160714.pdf -------------------------------------------------------------------------------- /ShinyProject/.Rproj.user/687DFF8D/pcs/source-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "activeTab" : 0 3 | } -------------------------------------------------------------------------------- /ShinyProject/text2.csv: -------------------------------------------------------------------------------- 1 | id,value 2 | 1,100 3 | 2,200 4 | 3,300 5 | 4,400 6 | 5,500 7 | -------------------------------------------------------------------------------- /checkBoxFORggplot/.Rproj.user/687DFF8D/saved_source_markers: -------------------------------------------------------------------------------- 1 | {"active_set":"","sets":[]} -------------------------------------------------------------------------------- /ShinyProject/text3.csv: -------------------------------------------------------------------------------- 1 | id,value 2 | 1,1000 3 | 2,2000 4 | 3,3000 5 | 4,4000 6 | 5,5000 7 | -------------------------------------------------------------------------------- /checkBoxFORggplot/.Rproj.user/687DFF8D/pcs/source-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "activeTab" : 1 3 | } -------------------------------------------------------------------------------- /RSummer_20160711intro.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pecu/RSummer/HEAD/RSummer_20160711intro.pdf -------------------------------------------------------------------------------- /checkBoxFORggplot/.Rproj.user/687DFF8D/sdb/prop/B4B9E96: -------------------------------------------------------------------------------- 1 | { 2 | "tempName" : "Untitled1" 3 | } -------------------------------------------------------------------------------- /20160719/data/lottoryHistDf.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pecu/RSummer/HEAD/20160719/data/lottoryHistDf.RData -------------------------------------------------------------------------------- /20160719/install_packages.R: -------------------------------------------------------------------------------- 1 | install.packages("rvest") 2 | install.packages("httr") 3 | install.packages("dplyr") 4 | install.packages("stringr") -------------------------------------------------------------------------------- /ShinyProject/.Rproj.user/687DFF8D/pcs/workbench-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "TabSet1" : 0, 3 | "TabSet2" : 3, 4 | "TabZoom" : { 5 | } 6 | } -------------------------------------------------------------------------------- /checkBoxFORggplot/.Rproj.user/687DFF8D/pcs/workbench-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "TabSet1" : 0, 3 | "TabSet2" : 0, 4 | "TabZoom" : { 5 | } 6 | } -------------------------------------------------------------------------------- /checkBoxFORggplot/.Rproj.user/687DFF8D/viewer-cache/1839owj6fl.Rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pecu/RSummer/HEAD/checkBoxFORggplot/.Rproj.user/687DFF8D/viewer-cache/1839owj6fl.Rdata -------------------------------------------------------------------------------- /checkBoxFORggplot/.Rproj.user/687DFF8D/viewer-cache/a4syjw89dh.Rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pecu/RSummer/HEAD/checkBoxFORggplot/.Rproj.user/687DFF8D/viewer-cache/a4syjw89dh.Rdata -------------------------------------------------------------------------------- /checkBoxFORggplot/.Rproj.user/687DFF8D/viewer-cache/by9bmdgung.Rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pecu/RSummer/HEAD/checkBoxFORggplot/.Rproj.user/687DFF8D/viewer-cache/by9bmdgung.Rdata -------------------------------------------------------------------------------- /checkBoxFORggplot/.Rproj.user/687DFF8D/viewer-cache/qjvoixy435.Rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pecu/RSummer/HEAD/checkBoxFORggplot/.Rproj.user/687DFF8D/viewer-cache/qjvoixy435.Rdata -------------------------------------------------------------------------------- /ShinyProject/.Rproj.user/687DFF8D/pcs/files-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "path" : "C:/Users/pecu6/Desktop/NTU-CSX/R FinTech/code/ShinyProject", 3 | "sortOrder" : [ 4 | { 5 | "ascending" : true, 6 | "columnIndex" : 2 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /checkBoxFORggplot/.Rproj.user/687DFF8D/pcs/files-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "path" : "C:/Users/pecu6/Desktop/NTU-CSX/R FinTech/RSummer/checkBoxFORggplot", 3 | "sortOrder" : [ 4 | { 5 | "ascending" : true, 6 | "columnIndex" : 2 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /ShinyProject/ShinyProject.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /checkBoxFORggplot/ShinyProject.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /checkBoxFORggplot/rsconnect/shinyapps.io/pecu/checkBoxFORggplot.dcf: -------------------------------------------------------------------------------- 1 | name: checkBoxFORggplot 2 | account: pecu 3 | server: shinyapps.io 4 | appId: 116183 5 | bundleId: 512864 6 | url: https://pecu.shinyapps.io/checkBoxFORggplot/ 7 | when: 1469197816.57315 8 | asMultiple: FALSE 9 | asStatic: FALSE 10 | -------------------------------------------------------------------------------- /checkBoxFORggplot/data.R: -------------------------------------------------------------------------------- 1 | library(plyr) 2 | library(BBmisc) 3 | 4 | allType = 1:9 5 | df <- data.frame(x=rep(1:5, 9), val=sample(1:100, 45), 6 | variable=rep(paste0("category", 1:9), each=5)) 7 | allCategory =count(df$variable) 8 | checkboxList = convertRowsToList( 9 | data.frame(as.factor(allType), allCategory$x)) -------------------------------------------------------------------------------- /ShinyProject/.Rproj.user/687DFF8D/pcs/windowlayoutstate.pper: -------------------------------------------------------------------------------- 1 | { 2 | "left" : { 3 | "panelheight" : 807, 4 | "splitterpos" : 335, 5 | "topwindowstate" : "NORMAL", 6 | "windowheight" : 846 7 | }, 8 | "right" : { 9 | "panelheight" : 807, 10 | "splitterpos" : 505, 11 | "topwindowstate" : "NORMAL", 12 | "windowheight" : 846 13 | } 14 | } -------------------------------------------------------------------------------- /checkBoxFORggplot/.Rproj.user/687DFF8D/pcs/windowlayoutstate.pper: -------------------------------------------------------------------------------- 1 | { 2 | "left" : { 3 | "panelheight" : 807, 4 | "splitterpos" : 298, 5 | "topwindowstate" : "NORMAL", 6 | "windowheight" : 846 7 | }, 8 | "right" : { 9 | "panelheight" : 807, 10 | "splitterpos" : 507, 11 | "topwindowstate" : "NORMAL", 12 | "windowheight" : 846 13 | } 14 | } -------------------------------------------------------------------------------- /ShinyProject/.Rproj.user/687DFF8D/sdb/prop/INDEX: -------------------------------------------------------------------------------- 1 | C%3A%2FUsers%2Fpecu6%2FDesktop%2FNTU-CSX%2FR%20FinTech%2FRSummer%2FShinyProject%2Fserver.R="56D3CDAA" 2 | C%3A%2FUsers%2Fpecu6%2FDesktop%2FNTU-CSX%2FR%20FinTech%2FRSummer%2FShinyProject%2Fui.R="F7A8A7C4" 3 | C%3A%2FUsers%2Fpecu6%2FDesktop%2FNTU-CSX%2FR%20FinTech%2Fcode%2FShinyProject%2Fserver.R="F517D775" 4 | C%3A%2FUsers%2Fpecu6%2FDesktop%2FNTU-CSX%2FR%20FinTech%2Fcode%2FShinyProject%2Fui.R="3F068418" 5 | -------------------------------------------------------------------------------- /GAtest.R: -------------------------------------------------------------------------------- 1 | library(GA) 2 | 3 | # our goal is to find the following function 4 | f <- function(x) 5 | { 6 | 25-x*x 7 | } 8 | 9 | GAresult <- ga(type = "real-valued", 10 | f, 11 | min=0, 12 | max=100, 13 | popSize = 50, 14 | pcrossover = 0.8, 15 | pmutation = 0.1, 16 | elitism = 10, 17 | maxiter = 100) 18 | 19 | plot(GAresult) 20 | -------------------------------------------------------------------------------- /checkBoxFORggplot/ui.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | source("data.R") 3 | 4 | shinyUI(fluidPage( 5 | 6 | 7 | checkboxGroupInput("checkGroup", 8 | label = h3("Checkbox group"), 9 | choices = checkboxList, 10 | selected = 1), 11 | 12 | actionButton("SelectAll", label = "SelectAll"), 13 | actionButton("DelAll", label = "DelAll"), 14 | 15 | plotOutput("checkBoxPlot") 16 | 17 | )) -------------------------------------------------------------------------------- /HelloQuantmodTest.R: -------------------------------------------------------------------------------- 1 | rm(list=ls(all=TRUE)) 2 | library("quantmod") 3 | 4 | getSymbols("AAPL",src="yahoo") 5 | barChart(AAPL) 6 | chartSeries(AAPL,theme="white") 7 | chartSeries(AAPL["2007-05::2014-05"],theme="white") 8 | write.csv(AAPL, "AAPL.csv") 9 | 10 | ma_20<-runMean(AAPL[,4],n=20) 11 | addTA(ma_20,on=1,col="blue") 12 | ma_60<-runMean(AAPL[,4],n=60) 13 | addTA(ma_60,on=1,col="red") 14 | 15 | p<-Lag(ifelse(ma_20 ma_60[dateidx, 1] ) 34 | { 35 | p[dateidx] = 1 36 | } 37 | else 38 | { 39 | p[dateidx] = 0 40 | } 41 | return[dateidx] = return[dateidx] * p[dateidx] 42 | } 43 | } 44 | 45 | portfolio = cumsum(return) 46 | plot(portfolio) -------------------------------------------------------------------------------- /20160719/crawl_lottery_tables.R: -------------------------------------------------------------------------------- 1 | library(httr) 2 | library(rvest) 3 | library(stringr) 4 | 5 | url = "http://www.nfd.com.tw/lottery/49-year/49-2015.htm" 6 | tables = read_html(url) %>% html_table() 7 | dataTable = tables[[1]][-1,] 8 | colnames(dataTable) <- c("year","monthDay","YN","x1","x2","x3","x4","x5","x6","s","TN") 9 | 10 | # View(dataTable) 11 | 12 | getLotteryDf = function(url){ 13 | tables = read_html(url) %>% html_table() 14 | dataTable = tables[[1]][-1,] 15 | colnames(dataTable) <- c("year","monthDay","YN","x1","x2","x3","x4","x5","x6","s","TN") 16 | return(dataTable) 17 | } 18 | 19 | urls = sprintf("http://www.nfd.com.tw/lottery/49-year/49-%s.htm",2004:2016) 20 | 21 | lottoryHistDf = do.call(rbind, lapply(urls,getLotteryDf)) 22 | 23 | # View(lottoryHistDf) 24 | 25 | lottoryHistDf$x1 = str_replace_all(lottoryHistDf$x1," |[\r]|[\n]|[\t]|[$,\xe3\x80\x80]|[$,\xc2\xa0]","") 26 | lottoryHistDf$monthDay = str_replace_all(lottoryHistDf$monthDay," |[\r]|[\n]|[\t]","") 27 | monthDay = do.call(rbind,str_extract_all(lottoryHistDf$monthDay,pattern = "[0-9]+")) 28 | lottoryHistDf$month = monthDay[,1] 29 | lottoryHistDf$day = monthDay[,2] 30 | lottoryHistDf$id = 1:dim(lottoryHistDf)[1] 31 | 32 | save(lottoryHistDf,file = "data/lottoryHistDf.RData") -------------------------------------------------------------------------------- /parserPTT.R: -------------------------------------------------------------------------------- 1 | rm(list=ls(all=TRUE)) 2 | library(XML) 3 | library(bitops) 4 | library(RCurl) 5 | library(httr) 6 | 7 | orgURL = 'https://www.ptt.cc/bbs/movie/index' 8 | #orgURL = 'https://www.ptt.cc/bbs/StupidClown/index.html' 9 | 10 | startPage = 500 11 | endPage = 600 12 | alldata = data.frame() 13 | for( i in startPage:endPage) 14 | { 15 | pttURL <- paste(orgURL, i, '.html', sep='') 16 | urlExists = url.exists(pttURL) 17 | 18 | if(urlExists) 19 | { 20 | html = getURL(pttURL, ssl.verifypeer = FALSE) 21 | xml = htmlParse(html, encoding ='utf-8') 22 | title = xpathSApply(xml, "//div[@class='title']/a//text()", xmlValue) 23 | author = xpathSApply(xml, "//div[@class='author']", xmlValue) 24 | path = xpathSApply(xml, "//div[@class='title']/a//@href") 25 | date = xpathSApply(xml, "//div[@class='date']", xmlValue) 26 | response = xpathSApply(xml, "//div[@class='nrec']", xmlValue) 27 | tempdata = data.frame(title, author, path, date, response) 28 | } 29 | alldata = rbind(alldata, tempdata) 30 | } 31 | 32 | allDate = levels(alldata$date) 33 | res = hist(as.numeric(alldata$date), nclass=length(allDate), axes=F) 34 | axis(1, at=1:length(allDate), labels=allDate) 35 | axis(2, at=1:max(res$counts), labels=1:max(res$counts)) -------------------------------------------------------------------------------- /ShinyProject/.Rproj.user/687DFF8D/sdb/per/t/2683FB61: -------------------------------------------------------------------------------- 1 | { 2 | "collab_server" : "", 3 | "contents" : "library(shiny)\n\nshinyServer(function(input, output) {\n\n output$PlotFiles <- renderPlot({\n filename = paste('text', input$select, '.csv', sep=\"\")\n print(filename)\n x = read.csv(filename)\n plot(x)\n })\n \n output$text1 <- renderText({\n paste('your text is ', input$text, sep=\"\")\n })\n \n output$distPlot <- renderPlot({\n\n # generate bins based on input$bins from ui.R\n x <- faithful[, 2]\n bins <- seq(min(x), max(x), length.out = input$bins + 1)\n\n # draw the histogram with the specified number of bins\n hist(x, breaks = bins, col = 'darkgray', border = 'white')\n\n })\n\n})\n", 4 | "created" : 1469056594710.000, 5 | "dirty" : false, 6 | "encoding" : "UTF-8", 7 | "folds" : "", 8 | "hash" : "2177371097", 9 | "id" : "2683FB61", 10 | "lastKnownWriteTime" : 1469199293, 11 | "last_content_update" : 1469199293, 12 | "path" : "C:/Users/pecu6/Desktop/NTU-CSX/R FinTech/RSummer/ShinyProject/server.R", 13 | "project_path" : "server.R", 14 | "properties" : { 15 | }, 16 | "relative_order" : 2, 17 | "source_on_save" : false, 18 | "source_window" : "", 19 | "type" : "r_source" 20 | } -------------------------------------------------------------------------------- /ShinyProject/.Rproj.user/687DFF8D/sdb/per/t/F8136FCB: -------------------------------------------------------------------------------- 1 | { 2 | "collab_server" : "", 3 | "contents" : "library(shiny)\n\nshinyUI(fluidPage(\n\n # Application title\n titlePanel(\"Old Faithful Geyser Data\"),\n\n # Sidebar with a slider input for number of bins\n sidebarLayout(\n sidebarPanel(\n selectInput(\"select\", label = h3(\"Select box\"), \n choices = list(\"Choice 1\" = 1, \"Choice 2\" = 2,\n \"Choice 3\" = 3), selected = 1),\n \n textInput(\"text\", label = h3(\"Text input\"), \n value = \"Enter text...\"),\n \n sliderInput(\"bins\",\n \"Number of bins:\",\n min = 1,\n max = 50,\n value = 30)\n ),\n\n # Show a plot of the generated distribution\n mainPanel(\n plotOutput(\"PlotFiles\"),\n textOutput(\"text1\"),\n plotOutput(\"distPlot\")\n )\n )\n))\n", 4 | "created" : 1469056594524.000, 5 | "dirty" : false, 6 | "encoding" : "UTF-8", 7 | "folds" : "", 8 | "hash" : "1356348751", 9 | "id" : "F8136FCB", 10 | "lastKnownWriteTime" : 1469199293, 11 | "last_content_update" : 1469199293, 12 | "path" : "C:/Users/pecu6/Desktop/NTU-CSX/R FinTech/RSummer/ShinyProject/ui.R", 13 | "project_path" : "ui.R", 14 | "properties" : { 15 | }, 16 | "relative_order" : 1, 17 | "source_on_save" : false, 18 | "source_window" : "", 19 | "type" : "r_source" 20 | } -------------------------------------------------------------------------------- /SVMAAPL.R: -------------------------------------------------------------------------------- 1 | rm(list=ls(all=TRUE)) 2 | library('e1071') 3 | AAPL = read.csv('AAPL.csv') 4 | index = 1:nrow(AAPL) 5 | AAPL[,2:5] = log(AAPL[,2:5]) 6 | np = ceiling(0.1 * nrow(AAPL)) 7 | 8 | return = AAPL[2:nrow(AAPL), 5] - AAPL[1:(nrow(AAPL)-1), 5] 9 | return = append(return, 0, after=0) 10 | label = ifelse(return > 0, 1, 0) 11 | AAPL = cbind(AAPL, return, label) 12 | 13 | test.index = sample(1:nrow(AAPL), np) 14 | test.index = 1:np 15 | 16 | AAPL.test = AAPL[test.index, ] 17 | AAPL.train = AAPL[-test.index, ] 18 | 19 | tuned = tune.svm(label ~ ., data = AAPL.train, gamma = 10^(-3:-1), cost = 10^(-1:1)) 20 | summary(tuned) 21 | 22 | # 部分屬性 23 | APPLsub.train = AAPL.train[,c(2,4,5,9)] 24 | svm.model = svm(label ~ ., data = APPLsub.train, kernal='radial', type = 'C-classification', cost = 10, gamma = 0.1) 25 | # 全部屬性 26 | # svm.model = svm(label ~ ., data = AAPL.train, kernal='radial', type = 'C-classification', cost = 10, gamma = 0.1) 27 | 28 | # 部分屬性 29 | APPLsub.test = AAPL.test[, c(2,4,5,9)] 30 | svm.pred = predict(svm.model, APPLsub.test[, -9]) 31 | # 全部屬性 32 | # svm.pred = predict(svm.model, AAPL.test[, -9]) 33 | 34 | table.svm.test = table(pred = svm.pred, true = AAPL.test[, 9]) 35 | correct.svm = sum(diag(table.svm.test) / sum(table.svm.test)) * 100 36 | 37 | AAPL.test = cbind(AAPL.test[2:np,], AAPL.test[2:np,5] - AAPL.test[1:(np-1),5]) 38 | label = as.numeric(svm.pred)-1 39 | BuyAPPL = cbind(AAPL.test[,10], label[1:(np-1)]) 40 | return = exp(cumsum(BuyAPPL[,1] * BuyAPPL[,2])) 41 | plot(return) -------------------------------------------------------------------------------- /20160719/lottery_etl_viz.R: -------------------------------------------------------------------------------- 1 | ## load Data ## 2 | load("data/lottoryHistDf.RData") 3 | 4 | library(reshape2) 5 | library(dplyr) 6 | library(ggplot2) 7 | 8 | View(lot) 9 | 10 | ## choosing what you want ## 11 | lot <- lottoryHistDf %>% select(-c(monthDay, YN, TN, id)) 12 | 13 | ### 2016 ### 14 | lot %>% filter(year =="2016") %>% 15 | melt(id.vars = c("year", "month", "day")) %>% 16 | filter( variable != "s") %>% group_by(year, value) %>% 17 | summarise(count = n()) %>% ggplot(aes(x = value,y = count)) + geom_bar(stat = "identity") 18 | 19 | ### 2015 #### 20 | p <- lot %>% filter(year =="2015") %>% 21 | melt(id.vars = c("year", "month", "day")) %>% 22 | filter( variable != "s") %>% group_by(year, value) %>% 23 | summarise(count = n()) %>% ggplot(aes(x = value,y = count)) + geom_bar(stat = "identity") 24 | 25 | ## try choosing 2015 , get range ## 26 | lot %>% filter(year =="2015") %>% 27 | melt(id.vars = c("year", "month", "day")) %>% 28 | filter( variable != "s") %>% group_by(year, value) %>% 29 | summarise(count = n()) %>% filter(count == max(count) | count == min(count)) 30 | 31 | ## exercise ## 32 | lot %>% filter(year !="2016") %>% 33 | melt(id.vars = c("year", "month", "day")) %>% 34 | filter( variable != "s") %>% group_by(year, value) %>% 35 | summarise(count = n()) %>% select(year, count) %>% group_by(year) %>% 36 | summarise(min = min(count), max = max(count)) %>% 37 | View() 38 | 39 | 40 | #### Q: believe pattern ? #### 41 | lot.long <- lot %>% melt(id.vars = c("year", "month", "day")) 42 | lot.long %>% filter(variable != "s") %>% group_by(year, value) %>% 43 | summarise(count = n()) %>% arrange(desc(count)) %>% 44 | select(year, value) %>% group_by(year) %>% summarise(count = n()) %>% 45 | View() 46 | 47 | 48 | library(plotly) 49 | plot_ly(p) 50 | -------------------------------------------------------------------------------- /textMining.R: -------------------------------------------------------------------------------- 1 | rm(list=ls(all=TRUE)) 2 | # install.packages("jiebaR") 3 | # install.packages("tm") 4 | # install.packages("slam") 5 | #install.packages("RColorBrewer") 6 | # install.packages("wordcloud") 7 | # install.packages("topicmodels") 8 | # install.packages("igraph") 9 | 10 | library(jiebaRD) 11 | library(jiebaR) # 斷詞利器 12 | library(NLP) 13 | library(tm) # 文字詞彙矩陣運算 14 | library(slam) # 稀疏矩陣運算 15 | library(RColorBrewer) 16 | library(wordcloud) # 文字雲 17 | library(topicmodels) # 主題模型 18 | 19 | Sys.setlocale("LC_ALL", "cht") 20 | 21 | orgPath = "./subText" 22 | text = Corpus(DirSource(orgPath), list(language = NA)) 23 | text <- tm_map(text, removePunctuation) 24 | text <- tm_map(text, removeNumbers) 25 | text <- tm_map(text, function(word) 26 | { gsub("[A-Za-z0-9]", "", word) }) 27 | 28 | # 進行中文斷詞 29 | mixseg = worker() 30 | mat <- matrix( unlist(text), nrow=length(text) ) 31 | totalSegment = data.frame() 32 | for( j in 1:length(text) ) 33 | { 34 | for( i in 1:length(mat[j,]) ) 35 | { 36 | result = segment(as.character(mat[j,i]), jiebar=mixseg) 37 | } 38 | totalSegment = rbind(totalSegment, data.frame(result)) 39 | } 40 | 41 | totaldiff = levels(totalSegment$result) 42 | countMat = data.frame(totaldiff, c(rep(0, length(totaldiff)))) 43 | for( i in 1:length(totalSegment$result) ) 44 | { 45 | for( j in 1:length(totaldiff) ) 46 | { 47 | if( nchar(totaldiff[j]) >= 2 && 48 | totaldiff[j] == as.character(totalSegment$result[i]) ) 49 | { 50 | countMat[j,2] = countMat[j,2] + 1 51 | } 52 | } 53 | } 54 | 55 | names(countMat) = c("totaldiff", "freq") 56 | countMat[,2] = countMat[,2] / sum(countMat[,2]) 57 | 58 | wordcloud(countMat$totaldiff, countMat$freq, min.freq = 1, random.order = F, ordered.colors = T, 59 | colors = rainbow(length(totaldiff))) 60 | -------------------------------------------------------------------------------- /onePage.R: -------------------------------------------------------------------------------- 1 | rm(list=ls(all=TRUE)) 2 | # get html data 3 | library(XML) 4 | library(bitops) 5 | library(RCurl) 6 | library(NLP) 7 | library(httr) 8 | library(jiebaRD) 9 | library(jiebaR) # 斷詞利器 10 | library(NLP) 11 | library(tm) # 文字詞彙矩陣運算 12 | library(slam) # 稀疏矩陣運算 13 | library(RColorBrewer) 14 | library(wordcloud) # 文字雲 15 | library(topicmodels) # 主題模型 16 | 17 | Sys.setlocale("LC_ALL", "cht") 18 | 19 | pttURL = 'https://www.ptt.cc/bbs/movie/M.1468393456.A.0B2.html' 20 | html = getURL(pttURL, ssl.verifypeer = FALSE, encoding='UTF-8') 21 | xml = htmlParse(html, encoding='UTF-8') 22 | text = xpathSApply(xml, "//div[@id='main-content']", xmlValue) 23 | name = './onepage/ctest.txt' 24 | write(text, name) 25 | 26 | text = Corpus(DirSource('./onepage/'), list(language = NA)) 27 | text <- tm_map(text, removePunctuation) 28 | text <- tm_map(text, removeNumbers) 29 | text <- tm_map(text, function(word) 30 | { gsub("[A-Za-z0-9]", "", word) }) 31 | 32 | mixseg = worker() 33 | mat <- matrix( unlist(text), nrow=length(text) ) 34 | totalSegment = data.frame() 35 | for( i in 1:length(mat[1,]) ) 36 | { 37 | result = segment(as.character(mat[1,i]), jiebar=mixseg) 38 | print(result) 39 | totalSegment = rbind(totalSegment, data.frame(result)) 40 | } 41 | 42 | totaldiff = levels(totalSegment$result) 43 | countMat = data.frame(totaldiff, c(rep(0, length(totaldiff)))) 44 | for( i in 1:length(totalSegment$result) ) 45 | { 46 | for( j in 1:length(totaldiff) ) 47 | { 48 | if( nchar(totaldiff[j]) >= 2 && 49 | totaldiff[j] == as.character(totalSegment$result[i]) ) 50 | { 51 | countMat[j,2] = countMat[j,2] + 1 52 | } 53 | } 54 | } 55 | 56 | names(countMat) = c("diff", "freq") 57 | countMat$freq = countMat$freq / sum(countMat$freq) 58 | 59 | wordcloud(countMat$diff, countMat$freq, min.freq = 1, random.order = F, ordered.colors = T, 60 | colors = rainbow(length(totaldiff))) -------------------------------------------------------------------------------- /parserPTTandLevels.R: -------------------------------------------------------------------------------- 1 | rm(list=ls(all=TRUE)) 2 | library(XML) 3 | library(bitops) 4 | library(RCurl) 5 | library(httr) 6 | 7 | orgURL = 'https://www.ptt.cc/bbs/movie/index' 8 | #orgURL = 'https://www.ptt.cc/bbs/StupidClown/index.html' 9 | 10 | startPage = 500 11 | endPage = 600 12 | alldata = data.frame() 13 | for( i in startPage:endPage) 14 | { 15 | pttURL <- paste(orgURL, i, '.html', sep='') 16 | urlExists = url.exists(pttURL) 17 | 18 | if(urlExists) 19 | { 20 | html = getURL(pttURL, ssl.verifypeer = FALSE) 21 | xml = htmlParse(html, encoding ='utf-8') 22 | title = xpathSApply(xml, "//div[@class='title']/a//text()", xmlValue) 23 | author = xpathSApply(xml, "//div[@class='author']", xmlValue) 24 | path = xpathSApply(xml, "//div[@class='title']/a//@href") 25 | date = xpathSApply(xml, "//div[@class='date']", xmlValue) 26 | response = xpathSApply(xml, "//div[@class='nrec']", xmlValue) 27 | tempdata = data.frame(title, author, path, date, response) 28 | alldata = rbind(alldata, tempdata) 29 | } 30 | } 31 | 32 | # write data to csv file 33 | write.csv(alldata, 'alldata.csv') 34 | 35 | currentDate = c(1) 36 | currentVector = data.frame() 37 | inputdata = data.frame() 38 | currentPoint = 1 39 | currentVector = rbind(currentVector, data.frame(alldata$date[1])) 40 | names(currentVector) = c("diffdate") 41 | for( i in 1:length(alldata$date) ) 42 | { 43 | currentDate = alldata[i,4] 44 | if( as.numeric(currentDate[1]) != as.numeric(currentVector[currentPoint,1]) ) 45 | { 46 | inputdata = data.frame(currentDate[1]) 47 | names(inputdata) = c("diffdate") 48 | currentVector = rbind(currentVector, inputdata) 49 | currentPoint = currentPoint + 1 50 | } 51 | } 52 | 53 | allDate = currentVector$diffdate 54 | #allDate = levels(alldata$date) 55 | res = hist(as.numeric(alldata$date), nclass=length(allDate), axes=F, labels=T) 56 | axis(1, at=1:length(allDate), labels=allDate) 57 | axis(2, at=1:max(res$counts), labels=1:max(res$counts)) -------------------------------------------------------------------------------- /onePageDelChar.R: -------------------------------------------------------------------------------- 1 | rm(list=ls(all=TRUE)) 2 | # get html data 3 | library(XML) 4 | library(bitops) 5 | library(RCurl) 6 | library(NLP) 7 | library(httr) 8 | library(jiebaRD) 9 | library(jiebaR) # 斷詞利器 10 | library(NLP) 11 | library(tm) # 文字詞彙矩陣運算 12 | library(slam) # 稀疏矩陣運算 13 | library(RColorBrewer) 14 | library(wordcloud) # 文字雲 15 | library(topicmodels) # 主題模型 16 | library(plyr) 17 | 18 | Sys.setlocale("LC_ALL", "cht") 19 | 20 | pttURL = 'https://www.ptt.cc/bbs/movie/M.1468393456.A.0B2.html' 21 | html = getURL(pttURL, ssl.verifypeer = FALSE, encoding='UTF-8') 22 | xml = htmlParse(html, encoding='UTF-8') 23 | text = xpathSApply(xml, "//div[@id='main-content']", xmlValue) 24 | name = './onepage/ctest.txt' 25 | write(text, name) 26 | 27 | text = Corpus(DirSource('./onepage/'), list(language = NA)) 28 | text <- tm_map(text, removePunctuation) 29 | text <- tm_map(text, removeNumbers) 30 | text <- tm_map(text, function(word) 31 | { gsub("[A-Za-z0-9]", "", word) }) 32 | 33 | mixseg = worker() 34 | mat <- matrix( unlist(text), nrow=length(text) ) 35 | emptyId = which(mat == "") 36 | mat = t(matrix(mat[-emptyId])) 37 | 38 | totalSegment = data.frame() 39 | needChar = c("噓","推","爆","屌","拍") 40 | 41 | for( i in 1:length(mat[1,]) ) 42 | { 43 | result = segment(as.character(mat[1,i]), jiebar=mixseg) 44 | cid = length(result) 45 | delId = vector() 46 | print(result) 47 | for( j in 1:cid ) 48 | { 49 | if( nchar(result[j]) < 2 && 50 | is.element(result[j], needChar) == FALSE ) 51 | { 52 | delId = rbind(delId, j) 53 | print(j) 54 | } 55 | } 56 | print(delId) 57 | result = result[-delId] 58 | totalSegment = rbind(totalSegment, data.frame(result)) 59 | } 60 | reducedSegment = data.frame() 61 | reducedSegment = rbind(reducedSegment,data.frame(totalSegment$result[nchar(as.vector(totalSegment[,1]))>=2])) 62 | names(reducedSegment) = c("result") 63 | 64 | reduceDiff = count(reducedSegment$result) 65 | totaldiff = count(totalSegment$result) 66 | totaldiff$freq = totaldiff$freq / sum(totaldiff$freq) 67 | 68 | wordcloud(totaldiff$x, totaldiff$freq, min.freq = 1, random.order = F, ordered.colors = T, 69 | colors = rainbow(length(totaldiff$x))) -------------------------------------------------------------------------------- /20160719/quantmod_ML_PCA.R: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | ### SubWin_Samplers.Forward_Samplor 3 | ###################################################################### 4 | 5 | SubWin_Samplers.Forward_Samplor = function (x.xts, SubWin_Size = 20, Events_Dates = NULL, normailize = TRUE, 6 | BasePrice_Gen = NULL) 7 | { 8 | if (class(Events_Dates) == "character") 9 | Events_Dates <- as.Date(Events_Dates) 10 | 11 | XTS_Dates = rownames(as.matrix(x.xts)) 12 | if (is.null(Events_Dates)) { 13 | SubWins_Dates_Index = 1:length(XTS_Dates) 14 | SubWins_Dates = XTS_Dates 15 | } 16 | else { 17 | SubWins_Dates_Index = which(XTS_Dates %in% Events_Dates) 18 | SubWins_Dates = XTS_Dates[SubWins_Dates_Index] 19 | } 20 | XTS_Length = length(XTS_Dates) 21 | if (SubWin_Size > 0) { 22 | SubWins_Dates_Index = SubWins_Dates_Index[which((XTS_Length - 23 | SubWins_Dates_Index) > SubWin_Size)] 24 | SubWins_Dates = XTS_Dates[SubWins_Dates_Index] 25 | SubWins_Index = cbind(SubWins_Dates, XTS_Dates[SubWins_Dates_Index + 26 | SubWin_Size]) 27 | SubWins_Index = apply(SubWins_Index, 1, function(xx) paste(xx[1], 28 | xx[2], sep = "::")) 29 | } 30 | else { 31 | SubWins_Index = paste(SubWins_Dates, "::", sep = "") 32 | } 33 | if (normailize) { 34 | SubWins = lapply(SubWins_Index, function(xx) { 35 | SubWin_XTS = x.xts[xx, ] 36 | BasePrice = ifelse(test = is.null(BasePrice_Gen), 37 | yes = as.numeric(SubWin_XTS[1, 1]), no = BasePrice_Gen(SubWin_XTS)) 38 | SubWin_XTS = (SubWin_XTS - BasePrice)/BasePrice 39 | return(list(BasePrice = BasePrice, ReturnSubWin = SubWin_XTS)) 40 | }) 41 | return(SubWins) 42 | } 43 | else { 44 | SubWins = lapply(SubWins_Index, function(xx) { 45 | SubWin_XTS = x.xts[xx, ] 46 | return(list(ReturnSubWin = SubWin_XTS)) 47 | }) 48 | return(SubWins) 49 | } 50 | } 51 | 52 | ###################################################################### 53 | ### try SubWin_Samplers.Forward_Samplor 54 | ###################################################################### 55 | 56 | Xt = getSymbols("^SOX",from="2001-01-01",auto.assign = F) 57 | 58 | WinSize = 20 59 | sampleData = SubWin_Samplers.Forward_Samplor(x.xts=Cl(Xt),SubWin_Size=WinSize) 60 | head(sampleData) 61 | 62 | ###################################################################### 63 | ### PCA 64 | ###################################################################### 65 | 66 | rawData = do.call(rbind,lapply(sampleData,function(xx) as.numeric(xx$ReturnSubWin))) 67 | model = princomp(rawData) 68 | model$center 69 | 70 | eigen_vecs = t(model$loadings) 71 | 72 | drawFirstN = 5 73 | par(mar=c(1,1)) 74 | plot(1:(WinSize+1),eigen_vecs[1,],type="l",ylim=c(-0.3,0.3)) 75 | for (i in 2:drawFirstN){ 76 | points(1:(WinSize+1),eigen_vecs[i,],type="l",col=i) 77 | } -------------------------------------------------------------------------------- /20160719/quantmod_ML_classification.R: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | ### try SubWin_Samplers.Forward_Samplor 3 | ###################################################################### 4 | 5 | library(quantmod) 6 | 7 | Xt = getSymbols("^SOX",from="2001-01-01",auto.assign = F) 8 | 9 | # lag(xts) 10 | head(Xt) 11 | head(lag(Xt)) 12 | head(lag(Xt,3)) 13 | 14 | head(Xt) 15 | head(lag(Xt,-3)) 16 | 17 | ###################################################################### 18 | ### Labeling Events 19 | ###################################################################### 20 | 21 | Diff = lag(Cl(Xt),-1) - Cl(Xt) 22 | Diff = Diff[-NROW(Xt)] 23 | Labels = sign(Diff) 24 | 25 | ###################################################################### 26 | ### Feature Engineering 27 | ###################################################################### 28 | 29 | # MAs 30 | MA_Series = c(5,10,20,60) 31 | MA_Series_Features = SMA(Cl(Xt),5) 32 | 33 | for (i in MA_Series[-1]){ 34 | MA_Series_Features = cbind(MA_Series_Features,SMA(Cl(Xt),i)) 35 | } 36 | 37 | colnames(MA_Series_Features)=unlist(lapply(MA_Series,function(x) paste("MA",x,sep=""))) 38 | head(MA_Series_Features,100) 39 | 40 | 41 | # KDs 42 | KD_Features = stoch(HLC(Xt)) 43 | 44 | # MACD 45 | MACD_Features = MACD(Cl(Xt)) 46 | 47 | 48 | Total_Features = cbind(MA_Series_Features,KD_Features,MACD_Features) 49 | 50 | ###################################################################### 51 | ### combine Labels and Features 52 | ###################################################################### 53 | 54 | Total_Data = as.data.frame(cbind(Labels,Total_Features)["2007-04-09::"]) 55 | head(Total_Data,100) 56 | colnames(Total_Data)[1] = "Labels" 57 | tail(Total_Data) 58 | Total_Data = Total_Data[!is.na(Total_Data$Labels),] 59 | Total_Data = Total_Data[!is.na(Total_Data$MA60),] 60 | 61 | 62 | ###################################################################### 63 | ### split Data 64 | ###################################################################### 65 | 66 | 67 | NData = NROW(Total_Data) 68 | Training_Index = sample(1:NData,size = 0.3*NData) 69 | Testing_Index = (1:NData)[-Training_Index] 70 | 71 | Training_Data = Total_Data[Training_Index,] 72 | Training_Y = as.factor(Training_Data$Labels) 73 | Training_X = Training_Data[,-1] 74 | 75 | 76 | Testing_Data = Total_Data[Testing_Index,] 77 | Testing_Y = as.factor(Testing_Data$Labels) 78 | Testing_X = Testing_Data[,-1] 79 | 80 | 81 | ##################################################################### 82 | ## SVM 83 | ##################################################################### 84 | 85 | library(e1071) 86 | svmModel = svm(x = Training_X,y = Training_Y,cost = 10) 87 | table(Testing_Y,predict(svmModel,Testing_X)) 88 | table(Training_Y,predict(svmModel,Training_X)) 89 | 90 | ##################################################################### 91 | ## Adaboost 92 | ##################################################################### 93 | 94 | library(ada) 95 | model = ada(x = Training_X,y = Training_Y,test.x = Testing_X,test.y = Testing_Y) 96 | table(Testing_Y,predict(model,Testing_X)) 97 | 98 | model$model$trees 99 | 100 | plot(model$model$trees[[1]]) 101 | text(model$model$trees[[1]], cex = .8) 102 | 103 | 104 | ##################################################################### 105 | ## spls 106 | ##################################################################### 107 | 108 | library(spls) 109 | model = splsda(x = as.matrix(Training_X),y = as.matrix(Training_Y),K = 1,eta = 0.9,kappa = 0.5) 110 | model 111 | table(Testing_Y,predict(model,Testing_X)) -------------------------------------------------------------------------------- /20160719/quantmod_ML_clustering.R: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | ### SubWin_Samplers.Forward_Samplor 3 | ###################################################################### 4 | 5 | SubWin_Samplers.Forward_Samplor = function (x.xts, SubWin_Size = 20, Events_Dates = NULL, normailize = TRUE, 6 | BasePrice_Gen = NULL) 7 | { 8 | if (class(Events_Dates) == "character") 9 | Events_Dates <- as.Date(Events_Dates) 10 | 11 | XTS_Dates = rownames(as.matrix(x.xts)) 12 | if (is.null(Events_Dates)) { 13 | SubWins_Dates_Index = 1:length(XTS_Dates) 14 | SubWins_Dates = XTS_Dates 15 | } 16 | else { 17 | SubWins_Dates_Index = which(XTS_Dates %in% Events_Dates) 18 | SubWins_Dates = XTS_Dates[SubWins_Dates_Index] 19 | } 20 | XTS_Length = length(XTS_Dates) 21 | if (SubWin_Size > 0) { 22 | SubWins_Dates_Index = SubWins_Dates_Index[which((XTS_Length - 23 | SubWins_Dates_Index) > SubWin_Size)] 24 | SubWins_Dates = XTS_Dates[SubWins_Dates_Index] 25 | SubWins_Index = cbind(SubWins_Dates, XTS_Dates[SubWins_Dates_Index + 26 | SubWin_Size]) 27 | SubWins_Index = apply(SubWins_Index, 1, function(xx) paste(xx[1], 28 | xx[2], sep = "::")) 29 | } 30 | else { 31 | SubWins_Index = paste(SubWins_Dates, "::", sep = "") 32 | } 33 | if (normailize) { 34 | SubWins = lapply(SubWins_Index, function(xx) { 35 | SubWin_XTS = x.xts[xx, ] 36 | BasePrice = ifelse(test = is.null(BasePrice_Gen), 37 | yes = as.numeric(SubWin_XTS[1, 1]), no = BasePrice_Gen(SubWin_XTS)) 38 | SubWin_XTS = (SubWin_XTS - BasePrice)/BasePrice 39 | return(list(BasePrice = BasePrice, ReturnSubWin = SubWin_XTS)) 40 | }) 41 | return(SubWins) 42 | } 43 | else { 44 | SubWins = lapply(SubWins_Index, function(xx) { 45 | SubWin_XTS = x.xts[xx, ] 46 | return(list(ReturnSubWin = SubWin_XTS)) 47 | }) 48 | return(SubWins) 49 | } 50 | } 51 | 52 | ###################################################################### 53 | ### try SubWin_Samplers.Forward_Samplor 54 | ###################################################################### 55 | 56 | Xt = getSymbols("^TWII",from="2001-01-01",auto.assign = F) 57 | 58 | WinSize = 20 59 | sampleData = SubWin_Samplers.Forward_Samplor(x.xts=Cl(Xt),SubWin_Size=WinSize) 60 | head(sampleData) 61 | 62 | ###################################################################### 63 | ### Kmenas Clustering 64 | ###################################################################### 65 | 66 | K_Centers = 7 67 | rawData = do.call(rbind,lapply(sampleData,function(xx) as.numeric(xx$ReturnSubWin))) 68 | model = kmeans(rawData,K_Centers,iter.max=50) 69 | 70 | # hint: $+TAB OR str 71 | model$ #+TAB 72 | str(model) 73 | names(model) 74 | 75 | ###################################################################### 76 | ### Plot Kmenas Clustering Results 77 | ###################################################################### 78 | 79 | layout(as.matrix(cbind(2:(K_Centers+1),2:(K_Centers+1),1,1))) 80 | layout.show((K_Centers+1)) 81 | par(mar=c(3,3,1,1)) 82 | barplot(model$size, horiz=TRUE) 83 | for (i in 1:K_Centers){ 84 | par(mar=c(2,2,1,1)) 85 | plot(1:(WinSize+1),model$centers[i,],type="l",col=i) 86 | } 87 | 88 | ###################################################################### 89 | ### Plot Centers 90 | ###################################################################### 91 | 92 | par(mar=c(1,1)) 93 | plot(1:(WinSize+1),model$centers[1,],type="l",ylim=c(-0.3,0.3)) 94 | for (i in 2:K_Centers){ 95 | points(1:(WinSize+1),model$centers[i,],type="l",col=i) 96 | } 97 | 98 | ###################################################################### 99 | ### DBSCAN Clustering 100 | ###################################################################### 101 | 102 | install.packages("fpc") 103 | library("fpc") 104 | 105 | model = dbscan(rawData,eps = 0.15) 106 | model 107 | 108 | model <- pamk(rawData,krange=3:5,criterion="asw",critout=TRUE) 109 | 110 | 111 | layout(as.matrix(cbind(2:(model$nc+1),2:(model$nc+1),1,1))) 112 | layout.show((model$nc+1)) 113 | 114 | size = 1:model$nc 115 | for (i in 1:model$nc){ 116 | size[i] = sum(model$pamobject$clustering==i) 117 | } 118 | barplot(size, horiz=TRUE) 119 | 120 | for (i in 1:model$nc){ 121 | par(mar=c(2,2,1,1)) 122 | plot(1:(WinSize+1),colMeans(rawData[model$pamobject$clustering==i,]),type="l",col=i) 123 | } -------------------------------------------------------------------------------- /checkBoxFORggplot/.Rhistory: -------------------------------------------------------------------------------- 1 | shiny::runApp() 2 | data.frame(matrix(1:10, 10:100, 100:1000)) 3 | data.frame(1:10, 10:100, 100:1000) 4 | c(1:10, 10:100, 100:1000, nrow=3) 5 | c(1:10, 10:100, 100:1000, nrow=3, ncol=10) 6 | x = data.frame(c(1:10, 10:100, 100:1000, nrow=3, ncol=10)) 7 | View(x) 8 | x = matrix(c(1:10, 10:100, 100:1000, nrow=3, ncol=10)) 9 | View(x) 10 | x = matrix(c(1:10, 10:100, 100:1000), nrow=3, ncol=10) 11 | x = matrix(c(20:40, 40:60, 60:80), nrow=3, ncol=10) 12 | 20:40 13 | matrix(c(20:40, 40:60, 60:80), nrow=3, ncol=21) 14 | View(x) 15 | plot(x) 16 | plot(x[1,]) 17 | plot(x[2,]) 18 | plot(x[3,]) 19 | plot(1:21, x) 20 | ggplot(x) 21 | library(ggplot2) 22 | ggplot(x) 23 | ggplot2(x) 24 | ggplot(x) 25 | ggplot(1:21, x) 26 | ggplot(data = x) 27 | df <- data.frame(x=rep(1:5, 9), val=sample(1:100, 45), 28 | variable=rep(paste0("category", 1:9), each=5)) 29 | View(df) 30 | ggplot(data = df, aes(x=x, y=val)) + geom_line(aes(colour=variable)) 31 | shiny::runApp() 32 | runApp() 33 | runApp() 34 | View(df) 35 | View(x) 36 | View(df) 37 | View(df) 38 | library(plyr) 39 | df <- data.frame(x=rep(1:5, 9), val=sample(1:100, 45), 40 | variable=rep(paste0("category", 1:9), each=5)) 41 | allCategory = list(count(df$variable)) 42 | allCategory 43 | allCategory$x 44 | allCategory[[1]]$x 45 | runApp() 46 | list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3) 47 | a = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3) 48 | count(df$variable) 49 | a = count(df$variable) 50 | View(a) 51 | allCategory = count(df$variable) 52 | View(allCategory) 53 | a = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3) 54 | allCategory = as.list(count(df$variable)) 55 | allCategory = as.list(t(count(df$variable))) 56 | count(df$variable) 57 | allCategory =count(df$variable) 58 | checkboxList = allCategory$x 59 | checkboxList = as.list(allCategory$x) 60 | checkboxList = as.list(allCategory$x, 1:9) 61 | checkboxList 62 | checkboxList[[1]] 63 | checkboxList[[2]] 64 | checkboxList[[2]][1] 65 | checkboxList[[2]][2] 66 | library(plyr) 67 | checkboxList = as.list(allCategory$x = 1:9) 68 | cbind(allCategory$x, allType) 69 | cbind(allCategory$x, t(allType)) 70 | allType = 1:9 71 | checkboxList = as.list(cbind(allCategory$x, t(allType))) 72 | allCategory$x 73 | checkboxList = as.list(cbind(allCategory$x, allType)) 74 | cbind(allCategory$x, allType) 75 | allCategory =count(df$variable) 76 | allCategory$x 77 | allType 78 | cbind(allCategory$x, as.factor(allType)) 79 | as.factor(allType) 80 | rbind(allCategory$x, as.factor(allType)) 81 | checkboxList = as.list(rbind(allCategory$x, as.factor(allType))) 82 | checkboxList = as.list(data.frame(allCategory$x, as.factor(allType))) 83 | data.frame(allCategory$x, as.factor(allType)) 84 | checkboxList = as.list(data.frame(allCategory$x, as.factor(allType))) 85 | checkboxList[[1]] 86 | checkboxList[[2]] 87 | checkboxList = as.list(as.data.frame(allCategory$x, as.factor(allType))) 88 | checkboxList = lapply( 89 | as.list(data.frame(allCategory$x, as.factor(allType)))) 90 | checkboxList = convertRowsToList( 91 | data.frame(allCategory$x, as.factor(allType))) 92 | install.packages("BBmisc") 93 | install.packages("BBmisc") 94 | checkboxList = convertRowsToList( 95 | data.frame(allCategory$x, as.factor(allType))) 96 | library(BBmisc) 97 | checkboxList = convertRowsToList( 98 | data.frame(allCategory$x, as.factor(allType))) 99 | library(plyr) 100 | library(BBmisc) 101 | allType = 1:9 102 | df <- data.frame(x=rep(1:5, 9), val=sample(1:100, 45), 103 | variable=rep(paste0("category", allType), each=5)) 104 | allCategory =count(df$variable) 105 | checkboxList = convertRowsToList( 106 | data.frame(allCategory$x, as.factor(allType))) 107 | shiny::runApp() 108 | runApp() 109 | runApp() 110 | runApp() 111 | runApp() 112 | as.character(c(1:length(allType))) 113 | checkboxList 114 | runApp() 115 | runApp() 116 | View(df) 117 | View(df) 118 | View(df) 119 | View(df) 120 | View(allCategory) 121 | View(df) 122 | runApp() 123 | View(df) 124 | runApp() 125 | View(allCategory) 126 | View(df) 127 | View(df) 128 | runApp() 129 | index = which(df$variable == i) 130 | i = 1 131 | index = which(df$variable == i) 132 | index 133 | df[index,1:2] 134 | val 135 | runApp() 136 | View(allCategory) 137 | View(df) 138 | runApp() 139 | ggplot(data = df[index,1:2]) 140 | index 141 | df[index,1:2] 142 | plot(data = df[index,1:2]) + geom_line(aes(colour=variable)) 143 | runApp() 144 | runApp() 145 | runApp() 146 | View(df) 147 | runApp() 148 | runApp() 149 | runApp() 150 | View(df) 151 | runApp() 152 | runApp() 153 | df$x[index,] 154 | index = c(1:5) 155 | df$x[index,] 156 | df$x[index] 157 | runApp() 158 | runApp() 159 | runApp() 160 | runApp() 161 | runApp() 162 | runApp() 163 | runApp() 164 | runApp() 165 | runApp() 166 | df <- data.frame(x=rep(1:5, 9), val=sample(1:100, 45), 167 | variable=rep(paste0("category", 1:9), each=5)) 168 | # plot 169 | ggplot(data = df, aes(x=x, y=val)) + geom_line(aes(colour=variable)) 170 | View(df) 171 | df <- data.frame(x=rep(1:5, 9), val=sample(1:100, 45), 172 | variable=rep(paste0("category", 1:9), each=5)) 173 | # plot 174 | ggplot(data = df[1:5,], aes(x=x, y=val)) + geom_line(aes(colour=variable)) 175 | df <- data.frame(x=rep(1:5, 9), val=sample(1:100, 45), 176 | variable=rep(paste0("category", 1:9), each=5)) 177 | # plot 178 | ggplot(data = df[1:10,], aes(x=x, y=val)) + geom_line(aes(colour=variable)) 179 | runApp() 180 | runApp() 181 | ggplot(data = df, aes(x=x, y=val)) + geom_line(aes(colour=variable)) 182 | df <- data.frame(x=rep(1:5, 9), val=sample(1:100, 45), 183 | variable=rep(paste0("category", 1:9), each=5)) 184 | # plot 185 | ggplot(data = df, aes(x=x, y=val)) + geom_line(aes(colour=variable)) 186 | View(df) 187 | runApp() 188 | runApp() 189 | runApp() 190 | View(df) 191 | df$variable[1] 192 | runApp() 193 | as.character(df$variable) 194 | runApp() 195 | shiny::runApp() 196 | shiny::runApp() 197 | -------------------------------------------------------------------------------- /gpaData.csv: -------------------------------------------------------------------------------- 1 | "","apply","pared","public","gpa" 2 | "1","very likely",0,0,3.25999999046326 3 | "2","somewhat likely",1,0,3.21000003814697 4 | "3","unlikely",1,1,3.94000005722046 5 | "4","somewhat likely",0,0,2.80999994277954 6 | "5","somewhat likely",0,0,2.52999997138977 7 | "6","unlikely",0,1,2.58999991416931 8 | "7","somewhat likely",0,0,2.55999994277954 9 | "8","somewhat likely",0,0,2.73000001907349 10 | "9","unlikely",0,0,3 11 | "10","somewhat likely",1,0,3.5 12 | "11","unlikely",1,1,3.65000009536743 13 | "12","somewhat likely",0,0,2.83999991416931 14 | "13","very likely",0,1,3.90000009536743 15 | "14","somewhat likely",0,0,2.6800000667572 16 | "15","unlikely",1,0,3.5699999332428 17 | "16","unlikely",0,0,3.08999991416931 18 | "17","unlikely",0,1,3.5 19 | "18","unlikely",0,0,2.17000007629395 20 | "19","very likely",0,1,3.35999989509583 21 | "20","somewhat likely",0,0,3.40000009536743 22 | "21","very likely",0,0,2.75 23 | "22","somewhat likely",1,0,3.20000004768372 24 | "23","unlikely",0,0,2.44000005722046 25 | "24","unlikely",0,0,2.82999992370605 26 | "25","unlikely",0,1,3 27 | "26","somewhat likely",0,1,3.26999998092651 28 | "27","somewhat likely",1,0,3.14000010490417 29 | "28","somewhat likely",0,0,3.36999988555908 30 | "29","very likely",0,1,2.78999996185303 31 | "30","unlikely",0,0,2.90000009536743 32 | "31","somewhat likely",0,0,3.38000011444092 33 | "32","unlikely",0,1,2.95000004768372 34 | "33","unlikely",0,0,2.98000001907349 35 | "34","unlikely",1,1,3.80999994277954 36 | "35","unlikely",0,0,2.74000000953674 37 | "36","unlikely",0,0,2.61999988555908 38 | "37","unlikely",0,0,2.84999990463257 39 | "38","somewhat likely",0,0,2.5 40 | "39","somewhat likely",0,0,2.75 41 | "40","unlikely",0,0,2.25999999046326 42 | "41","unlikely",0,0,2.02999997138977 43 | "42","somewhat likely",1,0,2.84999990463257 44 | "43","unlikely",0,0,2.72000002861023 45 | "44","somewhat likely",0,0,2.89000010490417 46 | "45","somewhat likely",1,0,2.47000002861023 47 | "46","unlikely",0,0,3.03999996185303 48 | "47","unlikely",0,0,3.09999990463257 49 | "48","unlikely",0,0,2.5699999332428 50 | "49","unlikely",0,0,2.08999991416931 51 | "50","somewhat likely",0,0,2.94000005722046 52 | "51","unlikely",0,0,3.45000004768372 53 | "52","unlikely",0,0,2.75999999046326 54 | "53","very likely",0,1,2.96000003814697 55 | "54","unlikely",0,0,2.89000010490417 56 | "55","somewhat likely",0,0,2.97000002861023 57 | "56","somewhat likely",0,1,3.91000008583069 58 | "57","somewhat likely",0,0,2.76999998092651 59 | "58","unlikely",0,0,2.50999999046326 60 | "59","unlikely",0,0,3.24000000953674 61 | "60","unlikely",0,0,2.44000005722046 62 | "61","somewhat likely",0,0,2.77999997138977 63 | "62","unlikely",0,0,2.94000005722046 64 | "63","unlikely",1,0,3.22000002861023 65 | "64","unlikely",0,0,3.5 66 | "65","very likely",1,0,3.5699999332428 67 | "66","somewhat likely",0,0,3.17000007629395 68 | "67","unlikely",0,1,3.23000001907349 69 | "68","unlikely",0,0,2.91000008583069 70 | "69","unlikely",0,0,3.27999997138977 71 | "70","unlikely",0,1,3.3199999332428 72 | "71","unlikely",0,0,3.61999988555908 73 | "72","unlikely",0,0,2.54999995231628 74 | "73","unlikely",0,0,2.97000002861023 75 | "74","very likely",1,0,3.63000011444092 76 | "75","unlikely",0,1,3.01999998092651 77 | "76","unlikely",0,1,3.59999990463257 78 | "77","unlikely",0,0,2.95000004768372 79 | "78","very likely",1,1,3.80999994277954 80 | "79","somewhat likely",1,0,2.6800000667572 81 | "80","unlikely",1,0,3.72000002861023 82 | "81","unlikely",0,0,2.49000000953674 83 | "82","unlikely",0,0,2.72000002861023 84 | "83","unlikely",1,0,2.25 85 | "84","unlikely",0,0,2.52999997138977 86 | "85","unlikely",0,0,3.25999999046326 87 | "86","very likely",0,0,2.5699999332428 88 | "87","unlikely",0,0,2.90000009536743 89 | "88","unlikely",0,0,3.04999995231628 90 | "89","somewhat likely",0,0,2.84999990463257 91 | "90","somewhat likely",0,0,4 92 | "91","very likely",1,0,3.40000009536743 93 | "92","somewhat likely",0,1,3.24000000953674 94 | "93","unlikely",0,1,3.50999999046326 95 | "94","very likely",0,0,2.54999995231628 96 | "95","unlikely",0,0,3.05999994277954 97 | "96","very likely",0,0,3 98 | "97","somewhat likely",0,0,3.13000011444092 99 | "98","unlikely",0,0,3.16000008583069 100 | "99","somewhat likely",0,0,2.47000002861023 101 | "100","somewhat likely",0,0,2.89000010490417 102 | "101","unlikely",0,0,2.74000000953674 103 | "102","unlikely",0,0,3.16000008583069 104 | "103","unlikely",0,0,2.92000007629395 105 | "104","somewhat likely",0,0,3.5699999332428 106 | "105","somewhat likely",1,0,3.49000000953674 107 | "106","somewhat likely",0,1,2.55999994277954 108 | "107","somewhat likely",1,0,3.11999988555908 109 | "108","somewhat likely",1,0,2.65000009536743 110 | "109","somewhat likely",0,0,2.50999999046326 111 | "110","somewhat likely",0,0,3.07999992370605 112 | "111","somewhat likely",0,0,2.65000009536743 113 | "112","unlikely",0,0,2.99000000953674 114 | "113","unlikely",0,0,2.63000011444092 115 | "114","somewhat likely",0,0,2.79999995231628 116 | "115","somewhat likely",0,1,3.46000003814697 117 | "116","unlikely",0,0,3.60999989509583 118 | "117","unlikely",0,0,3.07999992370605 119 | "118","unlikely",1,0,3.27999997138977 120 | "119","unlikely",0,1,3.30999994277954 121 | "120","unlikely",0,0,2.5699999332428 122 | "121","somewhat likely",0,0,3.39000010490417 123 | "122","unlikely",0,0,2.25999999046326 124 | "123","unlikely",0,0,2.42000007629395 125 | "124","unlikely",0,0,2.59999990463257 126 | "125","somewhat likely",1,1,3.44000005722046 127 | "126","somewhat likely",0,0,2.98000001907349 128 | "127","somewhat likely",1,0,3.08999991416931 129 | "128","unlikely",0,1,3.33999991416931 130 | "129","unlikely",0,0,2.83999991416931 131 | "130","unlikely",0,0,2.80999994277954 132 | "131","unlikely",0,0,2.78999996185303 133 | "132","unlikely",0,0,2.40000009536743 134 | "133","unlikely",0,0,3.01999998092651 135 | "134","somewhat likely",0,0,2.65000009536743 136 | "135","somewhat likely",0,0,2.54999995231628 137 | "136","somewhat likely",1,0,3.11999988555908 138 | "137","unlikely",0,0,2.98000001907349 139 | "138","very likely",1,0,3.60999989509583 140 | "139","unlikely",0,0,2.98000001907349 141 | "140","unlikely",0,0,3.19000005722046 142 | "141","unlikely",0,0,3.50999999046326 143 | "142","unlikely",0,0,3.09999990463257 144 | "143","unlikely",0,0,3.54999995231628 145 | "144","unlikely",0,0,2.98000001907349 146 | "145","very likely",0,0,2.99000000953674 147 | "146","unlikely",0,0,3.04999995231628 148 | "147","unlikely",0,0,2.99000000953674 149 | "148","unlikely",0,0,2.3199999332428 150 | "149","unlikely",0,0,2.5 151 | "150","unlikely",0,1,2.90000009536743 152 | "151","very likely",1,1,3.27999997138977 153 | "152","somewhat likely",0,0,2.95000004768372 154 | "153","somewhat likely",0,0,3.53999996185303 155 | "154","somewhat likely",0,0,3.10999989509583 156 | "155","unlikely",1,0,3.25 157 | "156","unlikely",0,0,2.44000005722046 158 | "157","unlikely",0,0,2.13000011444092 159 | "158","somewhat likely",0,0,3.22000002861023 160 | "159","somewhat likely",0,0,3.16000008583069 161 | "160","unlikely",0,0,3.39000010490417 162 | "161","somewhat likely",0,0,2.70000004768372 163 | "162","somewhat likely",0,0,3.08999991416931 164 | "163","somewhat likely",0,0,3.16000008583069 165 | "164","unlikely",0,0,2.27999997138977 166 | "165","unlikely",0,0,2.91000008583069 167 | "166","unlikely",0,0,3.65000009536743 168 | "167","unlikely",0,0,2.85999989509583 169 | "168","unlikely",0,1,3.39000010490417 170 | "169","unlikely",0,0,3.71000003814697 171 | "170","unlikely",0,0,3.25 172 | "171","unlikely",0,0,3.14000010490417 173 | "172","unlikely",0,0,2.41000008583069 174 | "173","somewhat likely",0,0,3.07999992370605 175 | "174","unlikely",0,1,3.01999998092651 176 | "175","somewhat likely",0,0,3.15000009536743 177 | "176","very likely",0,0,2.95000004768372 178 | "177","unlikely",0,0,2.22000002861023 179 | "178","somewhat likely",0,0,2.85999989509583 180 | "179","somewhat likely",1,0,2.88000011444092 181 | "180","very likely",0,0,2.61999988555908 182 | "181","unlikely",0,0,3.36999988555908 183 | "182","somewhat likely",0,0,3.50999999046326 184 | "183","somewhat likely",0,0,3.65000009536743 185 | "184","very likely",1,0,3.42000007629395 186 | "185","very likely",0,0,2.41000008583069 187 | "186","very likely",0,1,3.21000003814697 188 | "187","unlikely",0,0,3.22000002861023 189 | "188","unlikely",0,0,2.52999997138977 190 | "189","somewhat likely",0,0,2.64000010490417 191 | "190","unlikely",0,0,2.94000005722046 192 | "191","somewhat likely",0,0,2.55999994277954 193 | "192","unlikely",0,1,3.11999988555908 194 | "193","somewhat likely",0,0,3.33999991416931 195 | "194","unlikely",0,0,3.22000002861023 196 | "195","somewhat likely",0,0,3.04999995231628 197 | "196","somewhat likely",0,0,3.28999996185303 198 | "197","somewhat likely",0,0,2.71000003814697 199 | "198","unlikely",0,0,2.86999988555908 200 | "199","unlikely",0,0,3.28999996185303 201 | "200","unlikely",0,0,3.35999989509583 202 | "201","unlikely",1,1,2.84999990463257 203 | "202","unlikely",0,0,2.78999996185303 204 | "203","somewhat likely",0,0,3.69000005722046 205 | "204","very likely",0,0,3.55999994277954 206 | "205","unlikely",0,0,3.51999998092651 207 | "206","unlikely",1,1,3.38000011444092 208 | "207","very likely",0,1,3.10999989509583 209 | "208","somewhat likely",1,0,3.20000004768372 210 | "209","unlikely",0,0,2.82999992370605 211 | "210","unlikely",0,0,3.07999992370605 212 | "211","very likely",0,1,2.97000002861023 213 | "212","unlikely",0,0,2.64000010490417 214 | "213","unlikely",0,0,2.47000002861023 215 | "214","very likely",0,0,3.0699999332428 216 | "215","somewhat likely",0,0,3.20000004768372 217 | "216","unlikely",0,0,2.54999995231628 218 | "217","unlikely",0,0,2.48000001907349 219 | "218","unlikely",0,0,3.28999996185303 220 | "219","somewhat likely",0,0,2.64000010490417 221 | "220","somewhat likely",0,0,3.22000002861023 222 | "221","somewhat likely",1,0,2.79999995231628 223 | "222","somewhat likely",0,0,3.61999988555908 224 | "223","unlikely",0,0,2.61999988555908 225 | "224","somewhat likely",0,1,3.03999996185303 226 | "225","unlikely",0,1,2.49000000953674 227 | "226","unlikely",0,1,3.09999990463257 228 | "227","very likely",1,0,3.15000009536743 229 | "228","somewhat likely",0,0,2.65000009536743 230 | "229","unlikely",0,0,3.03999996185303 231 | "230","unlikely",0,1,3.04999995231628 232 | "231","unlikely",0,0,2.88000011444092 233 | "232","somewhat likely",0,0,2.85999989509583 234 | "233","somewhat likely",0,0,3 235 | "234","unlikely",0,0,2.23000001907349 236 | "235","unlikely",0,1,3.14000010490417 237 | "236","unlikely",0,0,2.67000007629395 238 | "237","unlikely",0,0,3.10999989509583 239 | "238","somewhat likely",0,0,3.73000001907349 240 | "239","somewhat likely",0,0,2.45000004768372 241 | "240","unlikely",0,0,3.03999996185303 242 | "241","unlikely",0,0,2.40000009536743 243 | "242","somewhat likely",0,0,3.4300000667572 244 | "243","somewhat likely",0,0,2.5699999332428 245 | "244","unlikely",0,0,2.83999991416931 246 | "245","unlikely",0,0,2.67000007629395 247 | "246","very likely",1,1,3.45000004768372 248 | "247","somewhat likely",1,0,2.88000011444092 249 | "248","somewhat likely",0,0,2.77999997138977 250 | "249","unlikely",0,0,3.22000002861023 251 | "250","unlikely",1,0,3.29999995231628 252 | "251","somewhat likely",1,0,2.85999989509583 253 | "252","somewhat likely",0,0,2.82999992370605 254 | "253","somewhat likely",0,0,3.70000004768372 255 | "254","somewhat likely",0,0,3.15000009536743 256 | "255","somewhat likely",1,1,3.07999992370605 257 | "256","unlikely",0,0,2.92000007629395 258 | "257","unlikely",0,0,2.89000010490417 259 | "258","very likely",1,0,3.52999997138977 260 | "259","unlikely",0,0,3.09999990463257 261 | "260","somewhat likely",1,0,3.35999989509583 262 | "261","somewhat likely",0,0,2.74000000953674 263 | "262","somewhat likely",0,0,2.73000001907349 264 | "263","unlikely",1,0,2.72000002861023 265 | "264","unlikely",0,0,3.52999997138977 266 | "265","unlikely",1,0,3.45000004768372 267 | "266","unlikely",0,0,2.98000001907349 268 | "267","somewhat likely",0,0,2.88000011444092 269 | "268","very likely",1,0,3.21000003814697 270 | "269","unlikely",0,0,3.05999994277954 271 | "270","unlikely",0,0,2.40000009536743 272 | "271","somewhat likely",0,0,3.5699999332428 273 | "272","unlikely",1,0,2.88000011444092 274 | "273","unlikely",0,0,3.26999998092651 275 | "274","unlikely",0,0,2.92000007629395 276 | "275","very likely",0,0,2.70000004768372 277 | "276","somewhat likely",1,0,2.52999997138977 278 | "277","somewhat likely",0,0,3.38000011444092 279 | "278","unlikely",0,0,3.16000008583069 280 | "279","somewhat likely",0,0,2.59999990463257 281 | "280","unlikely",0,0,2.75999999046326 282 | "281","unlikely",0,0,3.55999994277954 283 | "282","unlikely",0,0,2.86999988555908 284 | "283","somewhat likely",1,0,2.99000000953674 285 | "284","unlikely",0,0,2.6800000667572 286 | "285","unlikely",0,0,2.99000000953674 287 | "286","somewhat likely",0,0,2.96000003814697 288 | "287","unlikely",1,1,2.76999998092651 289 | "288","somewhat likely",0,0,3.27999997138977 290 | "289","unlikely",0,1,2.74000000953674 291 | "290","unlikely",0,0,1.89999997615814 292 | "291","unlikely",0,0,3.04999995231628 293 | "292","somewhat likely",0,1,2.44000005722046 294 | "293","somewhat likely",0,0,3.32999992370605 295 | "294","somewhat likely",0,1,3.55999994277954 296 | "295","unlikely",0,0,2.15000009536743 297 | "296","unlikely",0,0,2.82999992370605 298 | "297","somewhat likely",0,0,2.78999996185303 299 | "298","somewhat likely",0,0,2.72000002861023 300 | "299","very likely",1,0,3.03999996185303 301 | "300","unlikely",0,1,3.02999997138977 302 | "301","unlikely",0,0,2.88000011444092 303 | "302","somewhat likely",0,0,3.21000003814697 304 | "303","unlikely",0,0,2.74000000953674 305 | "304","unlikely",0,0,3.5699999332428 306 | "305","somewhat likely",0,0,2.4300000667572 307 | "306","unlikely",0,0,3.10999989509583 308 | "307","unlikely",0,0,2.75999999046326 309 | "308","somewhat likely",0,0,3.13000011444092 310 | "309","unlikely",0,0,2.75 311 | "310","unlikely",0,0,2.59999990463257 312 | "311","unlikely",0,0,3.67000007629395 313 | "312","unlikely",0,0,3.25999999046326 314 | "313","unlikely",0,0,3.41000008583069 315 | "314","very likely",0,0,3.24000000953674 316 | "315","unlikely",0,0,3.04999995231628 317 | "316","somewhat likely",1,0,2.38000011444092 318 | "317","somewhat likely",0,0,2.60999989509583 319 | "318","somewhat likely",1,1,3.1800000667572 320 | "319","unlikely",0,0,3.33999991416931 321 | "320","somewhat likely",0,0,2.83999991416931 322 | "321","unlikely",0,0,2.79999995231628 323 | "322","unlikely",0,0,3.21000003814697 324 | "323","unlikely",0,0,2.63000011444092 325 | "324","unlikely",0,0,2.30999994277954 326 | "325","unlikely",0,0,2.28999996185303 327 | "326","unlikely",0,0,3.50999999046326 328 | "327","somewhat likely",0,0,2.86999988555908 329 | "328","unlikely",0,0,3.08999991416931 330 | "329","somewhat likely",1,0,2.88000011444092 331 | "330","unlikely",1,0,2.47000002861023 332 | "331","somewhat likely",0,1,3.72000002861023 333 | "332","unlikely",0,0,3.20000004768372 334 | "333","somewhat likely",0,0,2.5699999332428 335 | "334","unlikely",0,0,3.04999995231628 336 | "335","unlikely",0,0,3.26999998092651 337 | "336","unlikely",0,0,3.29999995231628 338 | "337","unlikely",0,0,2.73000001907349 339 | "338","unlikely",1,0,2.63000011444092 340 | "339","unlikely",0,0,2.76999998092651 341 | "340","unlikely",0,0,3.15000009536743 342 | "341","unlikely",0,0,2.84999990463257 343 | "342","unlikely",0,0,2.25 344 | "343","somewhat likely",0,0,3.55999994277954 345 | "344","unlikely",0,0,2.70000004768372 346 | "345","very likely",0,0,2.94000005722046 347 | "346","somewhat likely",1,0,2.57999992370605 348 | "347","somewhat likely",0,0,2.97000002861023 349 | "348","very likely",0,0,3.38000011444092 350 | "349","very likely",0,0,2.96000003814697 351 | "350","unlikely",0,0,2.44000005722046 352 | "351","somewhat likely",0,1,3.75 353 | "352","somewhat likely",0,0,3.0699999332428 354 | "353","somewhat likely",0,0,2.72000002861023 355 | "354","unlikely",0,0,3.13000011444092 356 | "355","unlikely",0,0,3.39000010490417 357 | "356","unlikely",0,1,2.38000011444092 358 | "357","somewhat likely",0,0,2.86999988555908 359 | "358","unlikely",0,1,2.91000008583069 360 | "359","very likely",1,0,3.25 361 | "360","somewhat likely",1,1,3.50999999046326 362 | "361","unlikely",1,0,3.65000009536743 363 | "362","somewhat likely",0,0,3.10999989509583 364 | "363","very likely",0,0,2.71000003814697 365 | "364","unlikely",0,0,3.04999995231628 366 | "365","unlikely",0,0,2.9300000667572 367 | "366","somewhat likely",0,0,2.34999990463257 368 | "367","somewhat likely",0,0,2.49000000953674 369 | "368","unlikely",0,0,3.25999999046326 370 | "369","unlikely",0,0,3.76999998092651 371 | "370","unlikely",0,1,3.49000000953674 372 | "371","unlikely",0,0,3.39000010490417 373 | "372","unlikely",0,0,3.36999988555908 374 | "373","unlikely",0,0,1.98000001907349 375 | "374","unlikely",1,0,2.9300000667572 376 | "375","unlikely",0,0,3.35999989509583 377 | "376","unlikely",0,0,3.11999988555908 378 | "377","somewhat likely",0,0,3.23000001907349 379 | "378","somewhat likely",0,1,3.90000009536743 380 | "379","unlikely",0,0,2.70000004768372 381 | "380","unlikely",0,0,2.33999991416931 382 | "381","unlikely",0,0,3.29999995231628 383 | "382","somewhat likely",0,0,3.10999989509583 384 | "383","unlikely",0,0,3.14000010490417 385 | "384","somewhat likely",1,0,3.6800000667572 386 | "385","somewhat likely",0,0,2.22000002861023 387 | "386","unlikely",0,0,2.60999989509583 388 | "387","somewhat likely",0,1,3.48000001907349 389 | "388","very likely",0,0,3.07999992370605 390 | "389","unlikely",0,0,2.78999996185303 391 | "390","unlikely",0,0,3.11999988555908 392 | "391","unlikely",0,1,2.67000007629395 393 | "392","somewhat likely",0,0,3.53999996185303 394 | "393","very likely",0,0,2.98000001907349 395 | "394","somewhat likely",1,0,3.3199999332428 396 | "395","somewhat likely",1,0,3.53999996185303 397 | "396","unlikely",0,0,3.70000004768372 398 | "397","unlikely",0,0,2.63000011444092 399 | "398","somewhat likely",0,0,2.25 400 | "399","somewhat likely",0,0,3.25999999046326 401 | "400","very likely",0,0,3.51999998092651 402 | --------------------------------------------------------------------------------