This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### パッケージの準備 | |
# igraph、linkcommパッケージをインストール | |
install.packages("igraph") | |
install.packages("linkcomm") | |
# igraph、linkcommライブラリを読み込み | |
library(igraph) | |
library(linkcomm) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ライブラリの準備 | |
install.packages("igraph") | |
install.packages("linkcomm") | |
library(igraph) | |
library(linkcomm) | |
# データの準備 | |
d <- read.csv("08_imotodesse.csv", header=T) | |
g <- d[1:2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ライブラリの準備 | |
install.packages("igraph") | |
library(igraph) | |
# データの準備 | |
d <- read.csv("08_imotodesse.csv", header=T) | |
g <- graph.data.frame(d[1:2],directed=T) | |
### ネットワーク分析 | |
# ノード数、リンク数 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### パッケージの準備 | |
install.packages("igraph") | |
library(igraph) | |
### 木グラフ(ケーリー・ツリー) | |
graph1 <- graph.tree(20, mode = "undirected") #graph1に、ノードの数20で木グラフを作成 | |
plot(graph1) #graph1をプロット | |
average.path.length(graph1) #graph1の平均経路長を算出 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### パッケージの準備 | |
# igraphパッケージをインストール | |
install.packages("igraph") | |
# igraphライブラリを読み込み | |
library(igraph) | |
### データの準備 | |
# work_1.csvを読み込み、 dというオブジェクトに代入。1行目はヘッダー。エンコーディングはShift-JIS。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### twitterの特定ユーザがfollowしているユーザ間のfollowing関係を分析します。 | |
##### 下記では、@hentaimimura を例としています。 | |
### igraphパッケージの読み込み | |
library(igraph) | |
### データ読み込み(エッジリスト) | |
data <- read.csv("hentaimimura_following_list.csv", header=T) | |
nrow(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// マルコフ連鎖で1文を要約する | |
function markov(cell) { | |
var segmenter = new TinySegmenter(); // インスタンス生成 | |
var segs = segmenter.segment(cell); // 単語の配列が返る | |
var dic = makeDic(segs); | |
return makeSentence(dic); | |
} | |
// マルコフ連鎖で複数文を要約する | |
function markov_array(cells) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getAmazonPrice() { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var date = new Date(); | |
var row = sheet.getLastRow()+1; | |
sheet.getRange('A'+ row).setValue(date); | |
sheet.getRange('B'+ row) | |
.setFormula('=IMPORTXML(E1,"//td[@class=\'a-span12\']/span[@class=\'a-size-medium a-color-price\']")'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
アイテム名 | y | x1 | x2 | x3 | |
---|---|---|---|---|---|
【アサヒ飲料】十六茶 | 0 | 0 | 0 | 0 | |
【伊藤園】お~いお茶 濃い味 | 0 | 0 | 0 | 0 | |
【伊藤園】お~いお茶 緑茶 | 0 | 0 | 0 | 0 | |
【キリン】生茶 | 0 | 0 | 0 | 0 | |
【コカ・コーラ】綾鷹 | 0 | 0 | 0 | 1 | |
【コカ・コーラ】爽健美茶 | 0 | 0 | 1 | 0 | |
【サントリー】伊右衛門 | 0 | 0 | 0 | 1 | |
【大塚製薬】ポカリスエット | 0 | 0 | 0 | 0 | |
【コカ・コーラ】コカ・コーラ | 1 | 1 | 0 | 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
アイテム名 | 2392 | 2461 | 2739 | 3178 | |
---|---|---|---|---|---|
【アサヒ飲料】十六茶 | 0 | 0 | 0 | 0 | |
【伊藤園】お~いお茶 濃い味 | 0 | 0 | 0 | 0 | |
【伊藤園】お~いお茶 緑茶 | 0 | 0 | 0 | 0 | |
【キリン】生茶 | 0 | 0 | 0 | 0 | |
【コカ・コーラ】綾鷹 | 0 | 0 | 0 | 1 | |
【コカ・コーラ】爽健美茶 | 0 | 0 | 1 | 0 | |
【サントリー】伊右衛門 | 0 | 0 | 0 | 1 | |
【大塚製薬】ポカリスエット | 0 | 0 | 0 | 0 | |
【コカ・コーラ】コカ・コーラ | 1 | 1 | 0 | 0 |
NewerOlder