Slide 1

Slide 1 text

BeginneR Session - Data Analysis - #86 Tokyo.R 2020.06.27 @kilometer00

Slide 2

Slide 2 text

Who!? 誰だ?

Slide 3

Slide 3 text

Who!? 名前: 三村 @kilometer 職業: ポスドク (こうがくはくし) 専⾨: ⾏動神経科学(霊⻑類) 脳イメージング 医療システム⼯学 R歴: ~ 10年ぐらい 流⾏: 三体

Slide 4

Slide 4 text

・RStudio ・ Readable coding

Slide 5

Slide 5 text

・RStudio ・ Readable coding ・Tidy data ・Tidyverse

Slide 6

Slide 6 text

h"ps://rstudio.com/

Slide 7

Slide 7 text

Input Output

Slide 8

Slide 8 text

Integrated Development Environment RStudio h6ps://rstudio.com/ Recommended!!

Slide 9

Slide 9 text

RStudio

Slide 10

Slide 10 text

RStudio File > New File > R script (⌘ + ⇧ + N) Script Editor Console Files, Plots, Pkgs, ... Env., HIstoly, Git, ...

Slide 11

Slide 11 text

RStudio File > New File > R script (⌘ + ⇧ + N) Script Editor Console Files, Plots, Pkgs, ... Env., HIstoly, Git, ... ≈ Run

Slide 12

Slide 12 text

RStudio select, ⌘ + ↩ ≈ Run

Slide 13

Slide 13 text

Integrated Development Environment RStudio

Slide 14

Slide 14 text

RStudio

Slide 15

Slide 15 text

Projects RStudio

Slide 16

Slide 16 text

File > New Project > New Directory > New Project > Create New Project

Slide 17

Slide 17 text

my_project my_project.Rproj .Rproj.user ~/Documents/R Auto saved working information (Unsaved edits, tab order, etc.) Project Root folder Workspace setting Project Folder Open RStudio

Slide 18

Slide 18 text

my_project my_project.Rproj ~/Documents/R Project Folder data fig script.R

Slide 19

Slide 19 text

my_project my_project.Rproj ~/Documents/R Project Folder data fig script.R data_raw data_all.csv dat1.csv dat2.csv dat3.csv

Slide 20

Slide 20 text

my_project my_project.Rproj ~/Documents/R Project Folder data fig script.R data_raw data_all.csv dat <- read.csv("data/data_all.csv") Rela>ve path Project Root dat1.csv dat2.csv dat3.csv

Slide 21

Slide 21 text

~/Documents/R project1 project2 project3 project4

Slide 22

Slide 22 text

Project ≠ sandbox

Slide 23

Slide 23 text

Sandbox

Slide 24

Slide 24 text

Sandbox h)p://www.sandart-j.com/work/work3.html h)p://buzz-plus.com/2014/07/25/suna/

Slide 25

Slide 25 text

Sandbox A h+p://www.sandart-j.com/work/work3.html h+p://buzz-plus.com/2014/07/25/suna/ Sandbox B

Slide 26

Slide 26 text

Sandbox A h+p://www.sandart-j.com/work/work3.html h+p://buzz-plus.com/2014/07/25/suna/ Sandbox B Isolated & Independent

Slide 27

Slide 27 text

"Sandbox" in Python [python] version = "3.7" [packages] cycler==0.10.0 kiwisolver==1.1.0 matplotlib==3.1.1 numpy==1.16.4 opencv-python==4.1.0.25 pandas==0.25.0 pyparsing==2.4.0 PypeR==1.1.2 ... [python] version = "2.7" [packages] numpy==1.16.4 ... cf. hEps://speakerdeck.com/kilometer/tokyo-dot-r-number-80-r-interface-to-python

Slide 28

Slide 28 text

Sandbox environments?

Slide 29

Slide 29 text

R & RStudio Projects

Slide 30

Slide 30 text

h"ps://towardsdatascience.com/crea3ng-sandbox-environments-for-r-with-docker-def54e3491a3 If you want,

Slide 31

Slide 31 text

my_project my_project.Rproj ~/Documents/R "4dy" folder structure data fig script.R data_raw data_all.csv dat1.csv dat2.csv dat3.csv

Slide 32

Slide 32 text

『アンチ整理術』森 博嗣, 2019, ⽇本実業出版社

Slide 33

Slide 33 text

『アンチ整理術』森 博嗣, 2019, ⽇本実業出版社 整理・整頓する、という ⾏為には、デザインされた ⽅針が前提になっている。

Slide 34

Slide 34 text

ظ٭ذ 䗯㕔 㲔㏇ 鈝峮ס僗扛מ׻׼׍ 㰆㏇׊יַ׾׵סאס׵ס 㲔㏇؅瑞⺘⴫׊ג辐霄 䗯㕔סֹה䙫䓙⚥鷼٬ 鉮ꃿ٬⭚杼מ鸵׊ג ⫋⮵榫⺎耆ם׵ס 瑞⺘⴫ 鈝㴔 鈝峮 湳釶

Slide 35

Slide 35 text

&ODPEF "QQMF 3FBM "QQMF *OGPSNBUJPO %FDPEF

Slide 36

Slide 36 text

%JWFSHFODF 3FBM *OGP %BUB "QQMF &ODPEJOH

Slide 37

Slide 37 text

-PTT͛ Symbol grounding problem %JWFSHFODF 3FBM *OGP %BUB "QQMF &ODPEJOH

Slide 38

Slide 38 text

"QQMF &ODPEF 'SVJU 3FE JNBHF 3FBM *OGPSNBUJPO

Slide 39

Slide 39 text

"QQMF &ODPEF 'SVJU 3FE JNBHF 3FBM *OGPSNBUJPO DIBOOFM

Slide 40

Slide 40 text

『アンチ整理術』森 博嗣, 2019, ⽇本実業出版社 整理・整頓する、という ⾏為には、デザインされた ⽅針が前提になっている。

Slide 41

Slide 41 text

Exploratory Data Analysis

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

Exploratory Data Analysis "The Future of Data Analysis" Tukey, J. W., 1962 Three of the main strategies of data analysis are: 1. graphical presenta;on. 2. provision of flexibility in viewpoint and in facili;es, 3. intensive search for parsimony and simplicity. Brillinger, D. R., 2011

Slide 44

Slide 44 text

Exploratory Data Analysis "The Future of Data Analysis" Tukey, J. W., 1962 "Exploratory Data Analysis" Tukey, J. W., 1970 "Exploratory data analysis isolates pa3erns and features of the data and reveals these forcefully to the analyst" "Exploratory data analysis’ is an a:tude, a state of flexibility, a willingness to look for those things that we believe are not there, as well as those we believe to be there" Brillinger, D. R., 2011

Slide 45

Slide 45 text

Confirmatory (Hypothesis tes2ng) Exploratory Data analysis

Slide 46

Slide 46 text

Confirmatory (Hypothesis tes2ng) Exploratory Data analysis Tidy (needless to say) Un0dy Need to be thought of "2dy data" (because it isn't)

Slide 47

Slide 47 text

Confirmatory (Hypothesis tes2ng) Exploratory Data analysis

Slide 48

Slide 48 text

Confirmatory (Hypothesis tes2ng) Exploratory Data analysis Generalized procedures Improvisa2on

Slide 49

Slide 49 text

Data Pipeline spaghe. code!! spaghe. code? readable coding

Slide 50

Slide 50 text

Programing Write Run Read Think

Slide 51

Slide 51 text

Run!!! h&ps://www.amazon.co.jp/dp/B00Y0UI990/

Slide 52

Slide 52 text

Programing Write Run Read Think

Slide 53

Slide 53 text

Programing Write Run Read Think coding style

Slide 54

Slide 54 text

The %dyverse style guide h"ps://style.,dyverse.org/ "Good coding style is like correct punctua,on: you can manage without it, bu,tsuremakesthingseasiertoread." Google's R Style Guide h"ps://style.,dyverse.org/ "The goal of the R Programming Style Guide is to make our R code easier to read, share, and verify." R coding style guides

Slide 55

Slide 55 text

The %dyverse style guide h"ps://style.,dyverse.org/ "Good coding style is like correct punctua,on: you can manage without it, bu,tsuremakesthingseasiertoread." Google's R Style Guide h"ps://style.,dyverse.org/ "The goal of the R Programming Style Guide is to make our R code easier to read, share, and verify." R coding style guides

Slide 56

Slide 56 text

Programing Write Run Read Think Write Run Read Think Share

Slide 57

Slide 57 text

Text Figure Information Intention Data decode encode feedback Programing

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

・RStudio ・Readable coding ・Tidy data ・Tidyverse

Slide 61

Slide 61 text

Enjoy!!