16. sapply
sapply(X, FUN, ..., simplify = TRUE, USE.NAMES = TRUE)
Xの要素を1個ずつFUNの第1引数に渡してその結果をまとめて出力
> tmp <- sapply(list(a = "this is a", b = "this is b", c = "this is c"),
function(x) { cat("begin "); print(x); cat("end¥n"); return(x)})
begin [1] "this is a"
end
begin [1] "this is b"
end
begin [1] "this is c"
end
> tmp
a b c
"this is a" "this is b" "this is c"
17. つぶやかなかった日数
最も古いツイートと最新ツイートの間を対象とする
# 最も古いツイートから最新のツイートまでの日付
alldays <- format(seq(as.Date(dates[length(dates)]),
as.Date(dates[1]), by = "days"),
format = form) # form <- "%m/%d"
# days の因子
fdays <- factor(days, levels = alldays, order = TRUE)
# 日付ごとのつぶやき数
dtable <- table(fdays)
# つぶやき数が0の日付の数を出力
print(sum(dtable == 0))
出力
[1] 0
18. つぶやかなかった日数
最も古いツイートと最新ツイートの間を対象とする
# 最も古いツイートから最新のツイートまでの日付
alldays <- format(seq(as.Date(dates[length(dates)]),
as.Date(dates[1]), by = "days"),
format = form) # form <- "%m/%d"
# days の因子
fdays <- factor(days, levels = alldays, order = TRUE)
# 日付ごとのつぶやき数
dtable <- table(fdays)
# つぶやき数が0の日付の数を出力
print(sum(dtable == 0))
出力
[1] 0
ごめんなさい・・・
94. twitteRパッケージ
Description
As of July 2010, Twitter has changed their authentication
structure to require OAuth. Until such
a time that OAuth authentication is enabled in R and/or this
requirement changes, these functions
will not work properly.
【和訳】 認証の必要なデータは取得できなくなるよ