Tokyo.R#82 Data visualization

8284465a94bbdf1ea82cf1a67d55f447?s=47 kilometer
October 26, 2019

Tokyo.R#82 Data visualization

第82回Tokyo.Rでトークしたスライドです。

8284465a94bbdf1ea82cf1a67d55f447?s=128

kilometer

October 26, 2019
Tweet

Transcript

  1. BeginneR Session - データの可視化 - #82 Tokyo.R 2019.10.25 @kilometer00

  2. Who!?

  3. Who!? 名前: 三村 @kilometer 職業: ポスドク (こうがくはくし) 専⾨: ⾏動神経科学(霊⻑類) 脳イメージング

    医療システム⼯学 R歴: ~ 10年ぐらい 流⾏: 時差ぼけ
  4. 2019.01.19 Tokyo.R #75 BeginneR Session – Data pipeline 2019.03.02 Tokyo.R

    #76 BeginneR Session – Data pipeline 2019.04.13 Tokyo.R #77 BeginneR Session – Data analysis 2019.05.25 Tokyo.R #78 BeginneR Session – Data analysis 2019.06.29 Tokyo.R #79 BeginneR Session – 確率の基礎 2019.07.27 Tokyo.R #80 R Interface to Python 2019.09.29 Tokyo.R #81 IntRoduction & DemonstRation
  5. Before After BeginneR Session BeginneR BeginneR

  6. BeginneR Advanced Hoxo_m If I have seen further it is

    by standing on the shoulders of Giants. -- Sir Isaac Newton, 1676
  7. BeginneR Session - データの可視化 -

  8. Cave art Hieroglyphs

  9. Words Figures

  10. Words Beyond words Figures =

  11. Text Image Information Intention Data decode encode feedback

  12. Text Image First, A. Next, B. Then C. Finally D.

    time Intention encode "Frozen" structure A B C D time value α β
  13. https://en.wikipedia.org/wiki/Frank_Anscombe

  14. Francis Anscombe https://en.wikipedia.org/wiki/Frank_Anscombe

  15. "Graphs in Statistical Analysis" Anscombe, F.J. American Statistician 27 (1),

    1973
  16. "Graphs in Statistical Analysis" Anscombe, F.J. American Statistician 27 (1),

    1973 Most text books on statistical methods, and most statistical computer programs, pay too little attention to graphs.
  17. "Graphs in Statistical Analysis" Anscombe, F.J. American Statistician 27 (1),

    1973 Good statistical analysis ... should be sensitive both to peculiar features in given numbers and also whatever background information is available about the variables. 特異的な 変数 特徴量
  18. None
  19. None
  20. x y ?

  21. None
  22. Wide Long

  23. None
  24. library(tidyverse) anscombe %>% rowid_to_column("obs") %>% gather(key, val, -obs) %>% separate(key,

    into = c("xy", "No"), sep = 1L) %>% spread(xy, val) %>% select(No, obs, x, y) %>% arrange(No) -> dat
  25. Spark joy!!

  26. None
  27. dat %>% group_nest(No) %>% mutate(mean_x = map_dbl(data, ~mean(.$x)), mean_y =

    map_dbl(data, ~mean(.$y)), sd_x = map_dbl(data, ~sd(.$x)), sd_y = map_dbl(data, ~sd(.$y))) %>% mutate(model_lm = map(data, ~lm(y ~ x, data = .)), rsq = map_dbl(model_lm, ~summary(.) %>% .$r.sq), cor = map_dbl(data, ~cor(.$x, .$y)))
  28. None
  29. None
  30. x y mapping g <- ggplot(data = dat, mapping =

    aes(x = x, y = y)) data
  31. g <- g+ geom_smooth(method = "lm", se = F)+ geom_point()

    g <- ggplot(data = dat, aes(x = x, y = y)) 2. Add HFPN@ MBZFST 1. Create HHQMPU object with NBQQJOH g <- g+ facet_wrap(facets = ~ No, ncol = 4) 3. Set options
  32. g <- ggplot(data = dat, aes(x = x, y =

    y))+ geom_smooth(method = "lm", se = F)+ geom_point()+ facet_wrap(facets = ~ No, ncol = 4)+ theme_bw() ggsave("fig.png", g)
  33. Anscombe’s quartet

  34. install.packages("datasauRus") https://github.com/lockedata/datasauRus Download the Datasaurus: Never trust summary statistics alone;

    always visualize your data http://www.thefunctionalart.com/2016/08/download-datasaurus-never-trust-summary.html
  35. "Graphs in Statistical Analysis" Anscombe, F.J. American Statistician 27 (1),

    1973 Good statistical analysis ... should be sensitive both to peculiar features in given numbers and also whatever background information is available about the variables. 特異的な 変数 特徴量
  36. Summary...

  37. Words Beyond words Figures =

  38. Text Image Information Intention Data decode encode feedback

  39. Text Image First, A. Next, B. Then C. Finally D.

    time Intention encode "Frozen" structure A B C D time value α β
  40. x y ? mapping data

  41. Wide Long

  42. None
  43. x y mapping g <- ggplot(data = dat, mapping =

    aes(x = x, y = y)) data
  44. g <- g+ geom_smooth(method = "lm", se = F)+ geom_point()

    g <- ggplot(data = dat, aes(x = x, y = y)) 2. Add HFPN@ MBZFST 1. Create HHQMPU object with NBQQJOH g <- g+ facet_wrap(facets = ~ No, ncol = 4) 3. Set options
  45. g <- ggplot(data = dat, aes(x = x, y =

    y))+ geom_smooth(method = "lm", se = F)+ geom_point()+ facet_wrap(facets = ~ No, ncol = 4)+ theme_bw() ggsave("fig.png", g)
  46. Anscombe’s quartet

  47. "Graphs in Statistical Analysis" Anscombe, F.J. American Statistician 27 (1),

    1973 Unfortunately, most persons who have resources to a computer for statistical analysis of data are not much interested either in computer programming or in statistical method
  48. "Graphs in Statistical Analysis" Anscombe, F.J. American Statistician 27 (1),

    1973 Unfortunately, most persons who have resources to a computer for statistical analysis of data are not much interested either in computer programming or in statistical method ... It's time that was changed.
  49. Enjoy!!

  50. bar dradra