勉強会の懇親会で泥酔して履いていたランニングシューズを無くしたので新しい靴を買う必要がある。

せっかく買うなら少しは知識をつけていきたい。

ということで、ランナーが使っている靴の種類を調べる。

twitterからデータを取得

ハッシュタグnikeplusで、twitterから1000件データをとってくる。

library("twitteR")
setup_twitter_oauth(options()$CONSUMER_KEY, options()$CONSUMER_SECRET)
res <- searchTwitter("#nikeplus", n=1000, locale="ja")

Nike+からデータを取得

scrapeGPSパッケージでデータを取得する。

# install_github("dichika/scrapeGPS")
library("scrapeGPS")
library("dplyr")
urls <- lapply(res, function(x)x$urls$expanded_url)
urls <- unlist(urls)[grepl("http://go.nike.com", unlist(urls))]

data_attr <- NULL
for(i in seq(length(urls))){
  data_attr_ <- getNikeplus(urls[i], gps=FALSE)
  if(!is.data.frame(data_attr_)){
    next
    }
  data_attr <- rbind(data_attr, data_attr_)
  Sys.sleep(1)
  }

靴の種類をカウントする

各ユーザから先頭データを抽出して性別で靴の種類をカウントする。

なお中長距離ランナーは異常値なので除く。

data_shoes <- data_attr %>% filter(!is.na(shoes), 
                                   between(distance_km, 0, 3)
                                   ) %>% 
  group_by(name) %>% slice(1)
data_shoes %>% count(gender, shoes)
## Source: local data frame [28 x 3]
## Groups: gender
## 
##    gender                      shoes n
## 1       f                      Asics 1
## 2       f             Asics New York 1
## 3       f Black Adiddas tennis shoes 1
## 4       f               hgfftbuuuwik 1
## 5       f                  nike free 1
## 6       f              nike free run 1
## 7       f                pink tongue 1
## 8       m       GT-2000 ニューヨーク 1
## 9       m           New Balance 1210 1
## 10      m        Nike Air Relentless 1
## 11      m   Nike FS Trainers Lite II 1
## 12      m               Nike Free OG 1
## 13      m         Nike Zoom Vomero 9 1
## 14      m    Salomon Speedcross 3CS  1
## 15      m        adizero japan boost 1
## 16      m            air Pegasus 30+ 1
## 17      m                airmax 2015 1
## 18      m                      asics 1
## 19      m            brook pure grit 1
## 20      m              brooks bright 1
## 21      m                   free 4.0 1
## 22      m                       nike 1
## 23      m         nike lunarglide +5 1
## 24      m            nike shox green 1
## 25      m              nike zoom fly 1
## 26      m                     rebook 1
## 27      m                  sketchers 1
## 28      m                 コロンビア 1

だいたいわかった。

コロンビアで走っている人が気になる。あれトレッキングシューズじゃないのか。