Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fukuoka.R #15 順序尺度の時系列変化を
折れ線グラフとヒートマップで
可視化してみた

mitti1210
August 31, 2019

Fukuoka.R #15 順序尺度の時系列変化を
折れ線グラフとヒートマップで
可視化してみた

Fukuoka.R #15で発表したデータです。

データとコードをgithubに上げています。
https://github.com/mitti1210/myblog/blob/master/fukuokar_15.R

mitti1210

August 31, 2019
Tweet

More Decks by mitti1210

Other Decks in Science

Transcript

  1. ͦΕͧΕ1ʙ7఺ ߹ܭ18ʙ126఺ Ͱ͖Δೳྗ͕͋ͬͯ΋ ͍ͯ͠ͳ͚Ε͹ݮ఺ ӡಈ߲໨ ߲໨ ৯ࣄɾ੔༰ɾਗ਼১ɾߋҥʢ্ʣɾߋҥʢԼʣ τΠϨಈ࡞ɾഉ೘ίϯτϩʔϧɾഉศίϯτϩʔϧ ϕουҠ৐ɾτΠϨҠ৐ɾཋ૧Ҡ৐ าߦɾ֊ஈ

    ೝ஌߲໨ ߲໨ ཧղɾදग़ɾࣾձతަྲྀɾ໰୊ղܾɾهԱ ఺ ཱࣗ ෱ࢱ༻۩ͳ͠ ఺ ෱ࢱ༻۩͋Γ ఺ ݟकΓ ఺ հॿ հॿ ఺ հॿ ఺ հॿ ఺ Ҏ্ ॱংई౓
  2. Սۭσʔλ library(tidyverse) url <- "https://github.com/mitti1210/myblog/blob/master/fim.csv?raw=true" dat <- read.csv(url) names(dat) <-

    str_remove(names(dat), "FIM_") dat <- dat %>% select(-ӡಈ߹ܭ:-߹ܭ) dat_long <- dat %>% gather(key = key, value = value, ৯ࣄ:هԱ, factor_key = TRUE) dat_summarize <- dat_long %>% group_by(key, sheet) %>% summarize(mean = mean(value)) dat_count <- dat_long %>% group_by(key, sheet, value) %>% summarize(n = n())
  3. ·ͣ͸ંΕઢάϥϑ ggplot() + theme_classic(base_family = "HiraKakuPro-W3") + geom_line(data = dat_long,

    aes(x = sheet, y = value, group = ࢯ໊), color = "gray", alpha = 0.2) + geom_line(data = dat_summarize, aes(x = sheet, y = mean, group = key), color = "red", size = 1.5) + geom_text(data = dat_summarize, aes(x = sheet, y = mean, label = mean), vjust = -0.5) + facet_wrap(~ key) + labs(x = "", y = "")
  4. ώʔτϚοϓʹͯ͠Έͨ ggplot() + theme_gray(base_family = "HiraKakuPro-W3") + geom_tile(data = dat_count,

    aes(x = sheet, y = value, fill = n)) + scale_fill_gradientn(colours = c("yellow", "red")) + geom_text(data = dat_count, aes(x = sheet, y = value, label = n)) + facet_wrap(~ key)
  5. ંΕઢάϥϑͱώʔτϚοϓΛ ૊Έ߹ΘͤͯΈͨ ggplot() + theme_gray(base_family = "HiraKakuPro-W3") + geom_tile(data =

    dat_count, aes(x = sheet, y = value, fill = n)) + scale_fill_gradientn(colours = c("yellow", "red")) + geom_line(data = dat_long, aes(x = sheet, y = value, group = ࢯ໊), color = "gray", alpha = 0.2) + geom_line(data = dat_summarize, aes(x = sheet, y = mean, group = key), color = "red", size = 1.5) + geom_text(data = dat_count, aes(x = sheet, y = value, label = n)) + facet_wrap(~ key)