This file contains hidden or 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
#!/bin/bash | |
# RStudioでファイルを開き、"Run Script" ボタンで実行してください | |
cd $HOME | |
wget -Omecab-0.996.tar.gz 'https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7cENtOXlicTFaRUE' | |
wget -Omecab-ipadic-2.7.0-20070801.tar.gz 'https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7MWVlSDBCSXZMTXM' | |
tar xzvf mecab-0.996.tar.gz | |
cd mecab-0.996 | |
./configure --enable-utf8-only --prefix=$HOME/usr/local |
This file contains hidden or 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
# ファイルを開き、"Source" ボタンで実行してください | |
if(require("withr")){ | |
print("withr is loaded correctly") | |
} else { | |
print("trying to install withr...") | |
install.packages("withr") | |
if(require("withr")){ | |
print("withr installed and loaded") | |
} else { | |
stop("could not install withr") |
This file contains hidden or 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
#!/bin/bash | |
# RStudioでファイルを開き、"Run Script" ボタンで実行してください | |
# ご覧の通り、ただ pip コマンドを実行しているだけですので、 | |
# ターミナルを開いてコマンドが打てる方が対象 (学生、研修受講者) であれば | |
# わざわざこのスクリプトを実行する必要はありません | |
pip install sudachipy sudachidict_core sudachidict_full |
This file contains hidden or 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
## 参考: 【GoogleColaboratory】歌ネット(Uta-Net)から歌詞をスクレイピングする https://zenn.dev/robes/articles/00e86185677fb5 | |
library(tidyverse) | |
library(httr) | |
library(rvest) | |
base_url <- "https://www.uta-net.com" | |
#urls <- "https://www.uta-net.com/artist/6636/" | |
# とりあえずAKB48と乃木坂46と櫻坂46を選択 (オッサンには区別がつかないですが...) | |
urls <- c("https://www.uta-net.com/artist/6636/0/1/", "https://www.uta-net.com/artist/6636/0/2/", "https://www.uta-net.com/artist/12550/", "https://www.uta-net.com/artist/29512/") |
This file contains hidden or 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
# 「横浜市立学校 空気の見える化プロジェクト」(https://minnaair.com/blog/yokohama/) のデータを取得するRスクリプト | |
# タナカケンタ (鶴見教育工学研究所) | |
# https://mana.bi/ | |
# | |
# プロジェクトのWebページにアクセスし、データをスクレイピングし、整形するスクリプトです。 | |
# (どういうわけか) Webページの中に全期間の生データが直接書いてある🤪ので、それを取得しています。 | |
# 今後データが増えていったら、ページの読み込み速度がどんどん遅くなりそうですが... | |
# 現在のところ、2023/01/20頃から本運用が開始され、それ以降のデータがすべて取得できるようですので、 | |
# このスクリプトでは前回の結果からの差分を取る、といったことはしていません。 | |
# スクリプトの利用、改変はご自由にどうぞ。ただし、スクレイピングの間隔は空けて、サービス提供者の負荷に |
This file contains hidden or 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
library(stringi) | |
library(httr) | |
library(jsonlite) | |
names <- c("白石麻衣", "生田絵梨花", "齋藤飛鳥") | |
for (i in 1:length(names)){ | |
chars <- unlist(strsplit(names[i], split = "")) | |
for (j in 1:length(chars)){ | |
chars_ucs <- stri_escape_unicode(chars[j]) |
This file contains hidden or 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
### 自分のフォロワーのプロフィール情報を取得してワードクラウドを作る | |
library(twitteR) | |
library(RMeCab) | |
#library(wordcloud) | |
library(wordcloud2) | |
library(Cairo) | |
library(extrafont) | |
loadfonts(quiet = TRUE) | |
setup_twitter_oauth(consumer_key = "fAlW58d11EJ0UnSiWxUQydtSN", |
This file contains hidden or 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
library(tidyverse) | |
library(jsonlite) | |
library(leaflet) | |
library(htmlwidgets) | |
library(htmltools) | |
# 横浜市交通局バスロケーション情報の取得 | |
# APIキーはご自身で取得し、以下の "consumerKey=" 以降に付与してください。 | |
url <- "https://api.odpt.org/api/v4/odpt:Bus?odpt:operator=odpt.Operator:YokohamaMunicipal&acl:consumerKey=XXXXXXXXXXXXXXXXXX" |
This file contains hidden or 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
library(ChannelAttribution) | |
library(markovchain) | |
library(igraph) | |
library(ggplot2) | |
data(PathData) | |
H<-heuristic_models(Data,"path","total_conversions",var_value="total_conversion_value") | |
H | |
M<-markov_model(Data,"path","total_conversions",var_value="total_conversion_value",out_more=T) | |
M |
This file contains hidden or 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
# fivethirty eight color palette | |
# タナカケンタ (鶴見教育工学研究所) | |
# ggthemesパッケージで提供されているパレットが3色しかないため、Pythonのmatplotlibのstyle sheetから借用して6色に | |
# パレットの作り方は以下を参考にした | |
# https://meghan.rbind.io/blog/2022-10-11-creating-custom-color-palettes-with-ggplot2/ | |
fivethirtyeight_color <- function(...) { | |
fivethirtyeight_colors <- c( | |
`blue` = "#008fd5", |