20
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RでTwitter分析。指定キーワードの時間帯別ツイート数を可視化する。

Last updated at Posted at 2014-05-18

出力イメージ

Rplot01.jpeg

概要

指定キーワードの時間帯別ツイート数をRで可視化する。
Twitterでは、キーワードごとにツイートされやすい時間帯がある。
例えば、「おはよう」は朝にツイートされやすい。
この可視化により、そのキーワードを話題にしてもらいやすい時間帯が分かる。

作業

Rでネットワーク分析。指定Twitterユーザーのフォロー関係を可視化する。」の作業を行う。
ただし、コードの「#【本処理】」以降は下記のものに変更する。

TwitHoursHist.R
# 【本処理】

# Twitter検索キーワード
keyword.tgt <- '"島風くん"'
# Twitter検索対象日付
date.tgt <- "2014-05-17"
# Twitterで検索
date.next <- format(as.POSIXct(date.tgt) - 1, "%Y-%m-%d")
twt.raw <- searchTwitter(keyword.tgt, n = 1500, since = date.next, cainfo = cacert.name)
twt <- twListToDF(twt.raw)
twt$created.jst <- format(as.POSIXct(twt$created) + (3600 * 9), "%Y-%m-%d %H:%M:%S JST")
twt$created.jst.dt <- as.POSIXct(twt$created.jst, "JST") 
# 検索対象日付のものを抽出
twt.tgt <- twt[as.POSIXct(date.tgt, "JST") <= twt$created.jst.dt & twt$created.jst.dt < (as.POSIXct(date.tgt, "JST") + (3600 * 24)), ]
# 描画
hist(
  twt.tgt$created.jst.dt, 
  breaks = "hours",
  freq = T,
  col = "red",
  format = "%H時",
  main = paste('時間帯別ツイート数(', keyword.tgt, '、',date.tgt,')', sep = ""), 
  xlab = "時間帯", 
  ylab = "ツイート数")

感想

「島風くん」は夜の話題。(意味震)

20
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?