Skip to content

Instantly share code, notes, and snippets.

from pymongo import Connection
import datetime
setPath="ec2-54-248-156-148.ap-northeast-1.compute.amazonaws.com"
setDBS="ehanlin_103_jhs_db"
conn=Connection(setPath,27017)
db = conn[setDBS]
@Ray901
Ray901 / get_ESPN_NBA_boxscores.R
Last active September 30, 2015 00:17
web scraping ESPN NBA score box for R language
rm(list=ls())
tic<-Sys.time()
############################################################################
setDate<-"20150430"
############################################################################
@Ray901
Ray901 / server.R
Last active March 4, 2016 06:19
R shiny wordCloud
library(shiny)
library(rJava)
if (!require('Rwordseg')) {
install.packages("Rwordseg",repos = 'http://R-Forge.R-project.org')
}
library(Rwordseg)
if (!require('tm')) {
install.packages('tm')
}
library(tm)
@Ray901
Ray901 / pttTextMining.R
Last active August 29, 2015 14:18
mining ptt with R
rm(list=ls(all=TRUE))
library(rJava)
library(Rwordseg)
library(tm)
library(tmcn)
library(wordcloud)
library(XML)
library(RCurl)
library(googlesheets)
@Ray901
Ray901 / server.R
Last active August 29, 2015 14:20
R shiny app for EHanlin userExam
library(shiny)
library(dplyr)
library(rmongodb)
library(googleVis)
library(rPython)
sethost<-""
setdb_platform<-""
setdb_exam<-""
setdb_sim<-""
@Ray901
Ray901 / server.R
Last active August 29, 2015 14:20
R shiny app for questionInfo
library(shiny)
library(dplyr)
library(rmongodb)
library(googleVis)
sethost<-""
setdb_platform<-""
setdb_103exam<-""
setdb_102exam<-""
setdbUser<-""
@Ray901
Ray901 / R_Taiwan_plot.R
Last active February 2, 2023 10:16
plot Taiwan map with R
library(ggplot2)
library(maptools)
library(xlsx)
countyDat<-data.frame(Eng=c("Taipei","Taipei City","Taoyuan","Taichung","Taichung City","Tainan",
"Tainan City","Kaohsiung","Kaohsiung City","Ilan","Hsinchu","Miaoli",
"Changhwa","Nantou","Yunlin","Chiayi","Pingtung","Taitung","Hualien",
"Penghu","Keelung City","Hsinchu","Chiayi","Kinmen","Lienchiang"
),
@Ray901
Ray901 / TaiwanPopulationWiki.R
Last active August 29, 2015 14:24
scrape taiwan population From web wiki
rm(list=ls())
library(rvest)
webwiki <- html("https://zh.wikipedia.org/wiki/%E8%87%BA%E7%81%A3%E8%A1%8C%E6%94%BF%E5%8D%80%E4%BA%BA%E5%8F%A3%E5%88%97%E8%A1%A8")
population <- webwiki %>%
html_nodes("#bodyContent table") %>%
html_table()
#View(population[[1]])
@Ray901
Ray901 / createDF.py
Created July 27, 2015 10:30
use python to create dataFrame
import numpy as np
import pandas as pd
import string , random
def randomword(length):
return ''.join(random.choice(string.uppercase[0:5]) for i in range(length))
df1 = pd.DataFrame(list(randomword(50)),columns=['user'])
df2 = pd.DataFrame(np.random.randint(100, size=(50,2)),columns=['G1','G2'])
@Ray901
Ray901 / exam104.R
Last active August 29, 2015 14:26
load mongo exam104
rm(list=ls())
library(mongolite)
setAWSPath <- "ec2-54-238-68-224.ap-northeast-1.compute.amazonaws.com"
setDate <- c("")
m<-mongo(db = "ehanlin_104",
collection = "ExamAnswer",