library(quantmod)
## Warning: package 'quantmod' was built under R version 3.2.5
## Loading required package: xts
## Warning: package 'xts' was built under R version 3.2.5
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 3.2.5
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: TTR
## Warning: package 'TTR' was built under R version 3.2.5
## Version 0.4-0 included new data defaults. See ?getSymbols.
#?getSymbols
getSymbols("2330.TW")
## As of 0.4-0, 'getSymbols' uses env=parent.frame() and
## auto.assign=TRUE by default.
##
## This behavior will be phased out in 0.5-0 when the call will
## default to use auto.assign=FALSE. getOption("getSymbols.env") and
## getOptions("getSymbols.auto.assign") are now checked for alternate defaults
##
## This message is shown once per session and may be disabled by setting
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for more details.
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 128346 != reported length 200
## [1] "2330.TW"
chartSeries(`2330.TW`)

chartSeries(`2330.TW`, theme="white")

tw2330 = `2330.TW`
boxplot(as.data.frame(tw2330$`2330.TW.Close`))

getSymbols("2498.TW")
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 140593 != reported length 200
## [1] "2498.TW"
chartSeries(`2498.TW`)

chartSeries(`2498.TW`, theme="white")

library(quantmod)
stockdf <- `2330.TW`
names(stockdf)
## [1] "2330.TW.Open" "2330.TW.High" "2330.TW.Low"
## [4] "2330.TW.Close" "2330.TW.Volume" "2330.TW.Adjusted"
ma_20<-runMean(stockdf[,4],n=20)
ma_60<-runMean(stockdf[,4],n=60)
chartSeries(stockdf["2016-01-01::2016:05-28"],
theme="white",
up.col = "red",
dn.col = "green")

addTA(ma_20,on=1,col="red")

addTA(ma_60,on=1,col="blue")

head(cbind(stockdf[,4] , lag(stockdf[,4] , 1)))
## X2330.TW.Close X2330.TW.Close.1
## 2007-01-02 67.3632 NA
## 2007-01-03 67.6617 67.3632
## 2007-01-04 67.3632 67.6617
## 2007-01-05 66.5673 67.3632
## 2007-01-08 65.4727 66.5673
## 2007-01-09 65.6717 65.4727
ret = (stockdf[,4] - lag(stockdf[,4] , 1)) / lag(stockdf[,4] , 1)
head(cbind(stockdf[,4] , lag(stockdf[,4] , 1), ret))
## X2330.TW.Close X2330.TW.Close.1 X2330.TW.Close.2
## 2007-01-02 67.3632 NA NA
## 2007-01-03 67.6617 67.3632 0.004431203
## 2007-01-04 67.3632 67.6617 -0.004411654
## 2007-01-05 66.5673 67.3632 -0.011815056
## 2007-01-08 65.4727 66.5673 -0.016443509
## 2007-01-09 65.6717 65.4727 0.003039435
ret2 = dailyReturn(stockdf[,4])
head(cbind(stockdf[,4] , lag(stockdf[,4] , 1), ret, ret2))
## X2330.TW.Close X2330.TW.Close.1 X2330.TW.Close.2 daily.returns
## 2007-01-02 67.3632 NA NA 0.000000000
## 2007-01-03 67.6617 67.3632 0.004431203 0.004431203
## 2007-01-04 67.3632 67.6617 -0.004411654 -0.004411654
## 2007-01-05 66.5673 67.3632 -0.011815056 -0.011815056
## 2007-01-08 65.4727 66.5673 -0.016443509 -0.016443509
## 2007-01-09 65.6717 65.4727 0.003039435 0.003039435
week_ret = weeklyReturn(stockdf[,4])
month_ret = monthlyReturn(stockdf[,4])
hist(dailyReturn(stockdf[,4]))

抓取moneydj 新聞
library(rvest)
## Loading required package: xml2
url <- 'http://www.moneydj.com/KMDJ/News/NewsRealList.aspx?a=MB06'
domain <- 'http://www.moneydj.com'
res <- read_html(url)
newsurl <- res %>% html_nodes('#ctl00_ctl00_MainContent_Contents_sl_gvList a') %>% html_attr('href') %>% paste0(domain, x= .)
url1 <- 'http://www.moneydj.com/KMDJ/News/NewsViewer.aspx?a=f2503883-91fe-4927-b16c-d41eb2891c59&c=MB06'
res1 <- read_html(url1)
title <- res1 %>% html_nodes('#ctl00_ctl00_MainContent_Contents_lbTitle') %>% html_text() %>% iconv(from='UTF-8', to= 'UTF-8')
content <- res1 %>% html_nodes('article') %>% html_text() %>% iconv(from='UTF-8', to= 'UTF-8')
dt <- res1 %>% html_nodes('#ctl00_ctl00_MainContent_Contents_lbDate') %>% html_text() %>% iconv(from='UTF-8', to= 'UTF-8')
data.frame(Title = title, Content = content, DT = dt)
## Title
## 1 喬鼎加速內部變革步調與時程,下半年推多款新品
## Content
## 1 \r\n MoneyDJ新聞 2016-05-27 18:09:23 記者 張以忠 報導喬鼎(3057)董事長李志恩今(27)日表示,過去一年由於大環境變化劇烈,影響所及公司營運表現不如預期,但求新求變早已深入喬鼎資訊的基因,面對不確定的年代,喬鼎將加速內部變革的步調與時程,以更好的彈性與速度迎接挑戰開創未來;並提到,今(2016)年下半年將有多項新產品進入市場,包括於Apple Store開賣的個人雲裝置、超融合基礎架構系列產品,以及多媒體應用的Thunderbolt 3系列新品。李志恩表示,喬鼎從創立以來,每五年都會因應當時的市場變化轉型,求新求變的精神支撐我們在產業變遷中始終屹立不搖,而呼應變革的理念,喬鼎宣布依照產業解決方案概念,重新調整組織架構,分為物聯網(IoT)、雲端(Cloud)、企業資訊系統(IT)、多媒體(Rich Media)、監控(Surveillance)五大事業群,以快速反應市場需求。李志恩也指出,喬鼎下半年將有多項新產品進入市場,包括預計6/7於Apple Store開賣的個人與小眾團體之雲端同步分享設備Apollo Cloud、VSkyCube超融合基礎架構系列產品、與監控生態圈結合的Vess A系列產品(Surveillance)、預計於第3季或第4季問世的Thunderbolt 3系列新品,以及已開始規劃的新企業資訊系統Flash & Hybrid Storage產品系列。李志恩表示,在2000年之前,產品力夠好,加上合格的業務團隊,就有可能創造不錯的營運績效,但現在及未來幾年,光是產品力和業務力已經不足,行銷和生態體系的整合力,對提供多元解決方案的公司是必須強化的核心競爭力。李志恩表示,喬鼎依此方向擬定了今年的營運方針,並在年初著手轉型變革,進行「深化」和「廣化」的合縱連橫策略,包括將組織重整為專業分工、權責統一的五大事業部,以敏捷的執行力,讓產品研發與市場需求更深入的緊密結合,並且與上中下游的產業生態系中的廠商,進行技術與產品的整合,及行銷業務的結合,以創造共贏的方式,拓展更?廣的市場滲透,逐漸站?市場的領先地位。李志恩指出,在多路重兵出擊之下,今年下半年及2017年應可逐漸展現市場的成果。李志恩表示,轉型變革一定會經歷一段時間的陣痛,但相信以此廣化及深化的策略,配以敏捷的執行力,喬鼎有信心在未來幾年能有堅實的全球市場競爭力。\r\n \r\n\r\n
## DT
## 1 2016/05/27 18:09
parseDetail <- function(url){
res <- read_html(url)
content <- res %>% html_nodes('article') %>% html_text() %>% iconv(from='UTF-8', to='UTF-8')
title <- res %>% html_nodes('#ctl00_ctl00_MainContent_Contents_lbTitle') %>% html_text() %>% iconv(from='UTF-8', to='UTF-8')
dt <- res %>% html_nodes('#ctl00_ctl00_MainContent_Contents_lbDate') %>% html_text() %>% iconv(from='UTF-8', to='UTF-8')
data.frame(Title = title, Content = content, DT = dt)
}
stocknews <- lapply(newsurl, parseDetail)
newsdf <- do.call('rbind', stocknews)
newsdf$stockno <- lapply(newsdf$Content ,function(e) regmatches(x=e, regexpr("(\\d+)", e,perl=TRUE)))
news <- read.csv('moneydj201415_big5.csv', header=TRUE)
news[order(news$Viewer, decreasing = TRUE)[1:3], c('Title', 'Viewer')]
## Title Viewer
## 10524 三星搶頭香!全球首見10奈米FinFET技術舊金山展出 35935
## 13876 既生瑜何生亮?科技網站:hTC蝴蝶機3讓M9相形失色 22174
## 8367 旺季加持+新品熱銷,葡萄王本季營運衝鋒 22017
tb = table(news$StockNo)
barplot(tb[order(tb, decreasing=TRUE)[1:10]])

tw2317 = news[news$StockNo == '2317',]
2317
library(jiebaR)
## Warning: package 'jiebaR' was built under R version 3.2.5
## Loading required package: jiebaRD
## Warning: package 'jiebaRD' was built under R version 3.2.5
mixseg = worker()
c.tmp= news[news$StockNo == '2317','Content']
content.all <- sapply(c.tmp, function(e) segment(code= as.character(e) , jiebar = mixseg))
word <- unlist(content.all)
#edit_dict()
tb <- table(word)
tb <- sort(tb[tb >=30], decreasing = TRUE)
tb <- tb[nchar(names(tb)) >=2]
library(wordcloud)
## Warning: package 'wordcloud' was built under R version 3.2.5
## Loading required package: RColorBrewer
wordcloud(names(tb), tb, , min.freq = 1, random.order = F, ordered.colors = F, colors = rainbow(length(1:3)))
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 連接器 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 工具機 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : AppleWatch could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 電動車 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 為止 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 消費者 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 液晶面板 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 股票 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 應該 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : SDP could not be fit on page. It will not be plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 提出 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 擁有 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 平台 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 保護 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 情況 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 筆電 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 導光板 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 機殼 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 轉型 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 2016 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 月底 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 比例 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 本業 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 呈現 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 持有 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 針對 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 業者 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 成功 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 考慮 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 貢獻 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 高階 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 國內 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 液晶 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 連續 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 調查 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 公佈 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 出貨量 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 亞洲 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 淨利 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 最新 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 策略 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 電池 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 影片 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 數量 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 分析 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 支援 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 用戶 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 伺服器 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 位於 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 就是 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 華爾街日報 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 電子產品 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 截至 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 藍寶石 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : Android could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 一款 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 投資人 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 谷歌 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 旺季 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 消息 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 彭博社 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 也將 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 出現 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 此次 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 估計 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 完成 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 逐步 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 期間 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 製造業 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 還是 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 攝影機 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 2011 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 23 could not be fit on page. It will not be plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 了解 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 不同 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 之一 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 內部 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 加工 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 收盤 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 原本 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 原先 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 海外 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 執行長 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 情報 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 陸續 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 開發 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 微軟 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 資本 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 夥伴 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 增至 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 模組 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 人數 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 上季 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 引述 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 平均 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 但是 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 沒有 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 研究 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 高速 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 高達 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 售價 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 大增 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 公布 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 正達 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 先前 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 此外 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 取代 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 要求 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 最高 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 評等 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 關係 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 1000 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 一年 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 財報 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 產線 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 累計 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 軟體 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 陷入 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 新廠 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 萬元 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 製造商 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 17 could not be fit on page. It will not be plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : com could not be fit on page. It will not be plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 乙盛 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 內容 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 功能 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 金屬 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 退出 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 將是 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 授權 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 一個 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 申請 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 近年 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 南韓 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 庫存 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 許多 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 這款 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 通訊 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 富士 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 惠普 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 發現 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 僅有 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 優勢 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 營益 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 競爭 could not be fit on page. It will not be
## plotted.

2330
mixseg = worker()
c.tmp= news[news$StockNo == '2330','Content']
content.all <- sapply(c.tmp, function(e) segment(code= as.character(e) , jiebar = mixseg))
word <- unlist(content.all)
#edit_dict()
tb <- table(word)
tb <- sort(tb[tb >=30], decreasing = TRUE)
tb <- tb[nchar(names(tb)) >=2]
library(wordcloud)
wordcloud(names(tb), tb, , min.freq = 1, random.order = F, ordered.colors = F, colors = rainbow(length(1:3)))
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 減少 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 應該 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : iPhone6 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 也將 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 除了 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 將在 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : ARM could not be fit on page. It will not be plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 資料 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 趨勢 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 邏輯 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : Altera could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 能夠 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 解決方案 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 資訊 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 人士 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 似乎 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 近期 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 面臨 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 國內 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 提高 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 尺寸 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 代工廠 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 陸續 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 電源 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 降低 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 透露 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 通訊 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 預料 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 500 could not be fit on page. It will not be plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 支援 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 投資人 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 空間 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 花旗 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 核心 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 順利 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 廠房 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 2303 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : SamsungElectronicsCo could not be fit on page. It
## will not be plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 兩家 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 第二季 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 這些 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 連續 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 創下 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 開出 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 對於 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 製造商 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 獲得 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 2454 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 了解 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 人才 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 目標價 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 汽車 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 法說 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 挹注 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 清洗 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 逐漸 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 導入 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 中砂 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 之下 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 世界 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 必須 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 併購 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 股利 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 是否 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 現在 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 現金 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 辨識 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 韓國 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 公佈 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 系列 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 季增 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 金額 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 消息人士 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 高於 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 電池 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 歐洲 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : EUV could not be fit on page. It will not be plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 之間 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 太陽能 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 台股 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 利率 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 挑戰 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 員工 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 恩智浦 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 提前 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 測試 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 策略 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 階段 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 機台 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 聯發科 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : IBM could not be fit on page. It will not be plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : iPad could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : Nvidia could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 年減 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 來到 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 狀況 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 財測 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 部份 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 意味著 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 達成 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 機構 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 一年 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 日前 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 如今 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 百分點 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 呈現 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 則是 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 架構 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 甚至 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 第四季 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 進展 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 照明 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 電晶體 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 說明 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 領先 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 領導 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 營收將 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : HKMG could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : SamsungElectronics could not be fit on page. It will
## not be plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 之一 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 主因 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 地位 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 年底 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 投產 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 亞洲 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 保守 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 政府 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 原先 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 通過 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 就是 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 評等 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 買進 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 新興 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 試產 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 劉德音 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 導致 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 關於 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 23 could not be fit on page. It will not be plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 上揚 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 工作 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 平板 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 合肥 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 自家 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 快速 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 季減 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 股票 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 推升 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 統計 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 傳統 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 過熱 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 網路 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 德意志 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 擴大 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 擴充 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 2012 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 仍將 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 尤其 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 左右 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 佈局 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 特殊 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 針對 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 最高 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 資金 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 電視 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 繪圖 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 內部 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 世芯 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 召開 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 因素 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 成長率 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 即使 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 協力 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 面板廠 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 將是 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 帶來 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 普爾 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(names(tb), tb, , min.freq = 1, random.order = F,
## ordered.colors = F, : 釋出 could not be fit on page. It will not be
## plotted.

mixseg =worker()
#grepl('台積電', news$Content)
c.tmp= news[grepl('台積電', news$Content),'Content']
c.tmp = as.character(c.tmp)
library(tm)
## Loading required package: NLP
content.all=lapply(c.tmp, function(e)segment(code=e, jiebar=mixseg))
doc=VCorpus(VectorSource(content.all))
jieba_tokenizer=function(d){
unlist(segment(d[[1]],mixseg))
}
space_tokenizer=function(x){
unlist(strsplit(as.character(x[[1]]),'[[:space:]]+'))
}
doc=unlist(tm_map(doc,jieba_tokenizer),recursive=F)
doc=lapply(doc,function(d)paste(d,collapse=' '))
control.list=list(wordLengths=c(2,Inf),tokenize=space_tokenizer)
dtm=DocumentTermMatrix(Corpus(VectorSource(doc)),control=control.list)
#inspect(dtm)
#findAssocs(dtm, "台積電", 0.3)
關聯股票報酬
news2317= news[news$StockNo == '2317',]
str(news2317)
## 'data.frame': 319 obs. of 8 variables:
## $ X : int 33 121 135 182 194 199 215 384 467 520 ...
## $ ID : Factor w/ 8831 levels "M201401020001",..: 26 77 87 116 126 131 143 247 304 330 ...
## $ Title : Factor w/ 8830 levels "?北市土地公告現值再漲10.63%,並達市值9成",..: 173 6837 6503 6727 8497 4648 2169 339 4124 1011 ...
## $ Viewer : int 1571 1023 982 928 3034 1894 1330 2136 1660 809 ...
## $ Web : Factor w/ 8831 levels "http://www.moneydj.com/KMDJ/News/NewsViewer.aspx?a=%7B000a06ef-a4c1-4579-a0ff-acf1f2134b1a%7D",..: 7848 8133 4996 6360 3051 4076 6657 5603 5831 4288 ...
## $ Content : Factor w/ 8831 levels "?能集團(08105)以配售方式在創業板上市,擬配售1.25億股股份,其中8500萬股新股及4000萬股舊股,配售價介乎0.5元至0.7元。按配售價區間"| __truncated__,..: 5367 6794 7638 5819 5605 6919 6936 5424 5552 6927 ...
## $ StockNo : int 2317 2317 2317 2317 2317 2317 2317 2317 2317 2317 ...
## $ DateTime: Factor w/ 8515 levels "2014-01-02 09:39:00",..: 23 60 77 113 117 145 120 228 276 305 ...
news2317$Title = as.character(news2317$Title)
news2317$Content = as.character(news2317$Content)
news2317$DateTime = as.character(news2317$DateTime)
str(news2317)
## 'data.frame': 319 obs. of 8 variables:
## $ X : int 33 121 135 182 194 199 215 384 467 520 ...
## $ ID : Factor w/ 8831 levels "M201401020001",..: 26 77 87 116 126 131 143 247 304 330 ...
## $ Title : chr "《權民當家》iPhone銷售旺季到,鴻海/和碩報喜" "搶春節紅包,統一超攜鴻海推OPEN小將智慧機" "華碩5款新品CES亮相,並宣布攜AT&T;進軍美國" "傳大廠有意租用高軟IDC,鴻海:持開放態度" ...
## $ Viewer : int 1571 1023 982 928 3034 1894 1330 2136 1660 809 ...
## $ Web : Factor w/ 8831 levels "http://www.moneydj.com/KMDJ/News/NewsViewer.aspx?a=%7B000a06ef-a4c1-4579-a0ff-acf1f2134b1a%7D",..: 7848 8133 4996 6360 3051 4076 6657 5603 5831 4288 ...
## $ Content : chr "中國移動即將開賣蘋果商品,市場期待可望挹注2014年iPhone銷售數字,主要代工廠中的鴻海(2317)及和碩(4938)將是主要受惠個股,如果擔心"| __truncated__ "便利商店業者統一超(2912)從去年7月開始與鴻海(2317)合作推出一系列3C產品,繼電視相關產品、平板電腦、功能性手機(featurePhone)後,為"| __truncated__ "華碩(2317)董事長施崇棠今(7)日凌晨4點於拉斯維加斯召開記者會,舉辦CES國際新品發表會,會中發表智慧手機ZenFone系列,變形手機PadFone"| __truncated__ "市場傳出,鴻海(2317)位於高雄軟體園區的雲端資料中心(IDC),中國電子商務公司阿里巴巴有意租用,對此,鴻海表示,正積極規畫高雄軟體園"| __truncated__ ...
## $ StockNo : int 2317 2317 2317 2317 2317 2317 2317 2317 2317 2317 ...
## $ DateTime: chr "2014-01-02 17:33:00" "2014-01-06 13:23:00" "2014-01-07 08:30:00" "2014-01-08 18:45:00" ...
library(quantmod)
getSymbols("2317.TW")
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 153681 != reported length 200
## [1] "2317.TW"
stock2317 = `2317.TW`
class(stock2317)
## [1] "xts" "zoo"
# add return information
stock2317$daily_return = dailyReturn(stock2317[,4])
stock2317$weekly_return = weeklyReturn(stock2317[,4])
stock2317$monthly_return = monthlyReturn(stock2317[,4])
# convert to data frame
df2317 = as.data.frame(stock2317)
#head(df2317)
# Add date information
df2317$Date = rownames(as.data.frame(stock2317))
news2317$Date = lapply(news2317$DateTime, function(e)
strsplit(e, ' ' )[[1]][1] )
merge2317 = merge(x= df2317, y=news2317, by="Date")
m = merge2317[merge2317$daily_return > 0.03, c('Title', 'daily_return','Content')]