Skip to content

Instantly share code, notes, and snippets.

View whizzalan's full-sized avatar
🎯
Focusing

george chao whizzalan

🎯
Focusing
View GitHub Profile

R Packaegs 相關

tags: R, Packages

MRO 與 MRS 常會遇到的 MRAN 問題

由於 Microsoft R 會自己維護一個 CRAN, 會像是一個 Time Machine 紀錄每段期間相容的套件

@whizzalan
whizzalan / setup.md
Last active August 8, 2016 09:59 — forked from philipz/setup.md
Prepare Docker Swarm Environment

#On Local Machine Side ##Install Docker Engine, Docker Machine && Docker Compose ###Docker Engine sudo wget -qO- http://test.docker.com/ | sh ###Docker Machine Docker Machine Github

wget https://github.com/docker/machine/releases/download/v0.8.0-rc2/docker-machine-`uname -s`-`uname -m` && \
sudo mv docker-machine-`uname -s`-`uname -m` /usr/local/bin/docker-machine && \
sudo chmod +x /usr/local/bin/docker-machine
@whizzalan
whizzalan / TWSE.R
Created August 5, 2016 05:16
GET with error, url right
library(httr)
library(XML)
library(dplyr)
TWSE <- function(stock="1215",year_in,month_in){
url <- "http://www.twse.com.tw/en/trading/exchange/STOCK_DAY/STOCK_DAY.php"
year <- as.numeric(year_in)
month <- as.numeric(month_in)
query_str <- paste0('myear=', year, '&mmon=', month,
'&STK_NO=', stock, '&login_btn=+Query+')
res <- POST(url,

Pipeline Operator in R

Concepts of Pipeline

[^first]R is functional language, which means that your code often contains a lot of ( parentheses).

And complex code often means nesting those parentheses together, which make code hard to read and understand.

傳統寫法

Crontab 部署 R 爬蟲時需要注意的地方

  1. rvest::html_table 需要 import methods,稍微查過僅有 {xml2} -> {testhat} -> {methods}
  2. (測試用),在blogger會變白色....

This thread might shed some light on it. It seems that in some contexts RSCRIPT doesn't load package::methods by default, whereas interactive sessions do load it by default. It seems that the "when" is not clear, but explicitly calling library(methods) for all RSCRIPT executions seems to be the safe bet: can use package interactively, but Rscript gives errors.

@whizzalan
whizzalan / 1-RODBC.R
Created December 29, 2015 06:56 — forked from andrie/1-RODBC.R
Preview of using Revolution R Enterprise inside SQL Server 2016
### Connect to SQL Server using RODBC
library(RODBC)
library(magrittr)
# Connect to SQL Server using RODBC ------------------
sqlHost <- "DAA136209339.sys-sqlsvr.local"
sqlDatabase <- "RevoTestDB"
dsnString <- "driver={SQL Server};server=%s;database=%s;trusted_connection=true"