kilometer
January 20, 2018
620

# BeginnerSession2_67th_TokyoR

BeginnerSession2 alisw

January 20, 2018

## Transcript

1. ###         @kilometer Beginner’s

Session 2 -- data manipulation --
2. ### Who  @kilometer  Postdoc (Ph.D engineering)  Behavioral System

Neuro Imaging Medical System Engineering R ~ 10 years? : Kyoto
3. ### ’ Basic Technics to be Freedom in R Beginner to

Intermediate level

8. ### George Boole 1815 - 1864 A Class-Room Introduction to Logic

https://niyamaklogic.wordpress.co m/category/laws-of-thoughts/ Mathematician Philosopher &
9. ###  Boolean Algebra    George Boole 1815 -

1864       # equal to # not equal to # or # and # is A in B? wikipedia
10. ###  # is A in B?  Boolean Algebra 

  # is A in B?  

12. ### Basic Technics to be Freedom in R Pipe algebra Verb

functions data.frame
13. ### Basic Technics to be Freedom in R data.frame What is?

Access Handling
14. ### What is “data.frame” data.frame is a “list” looks like a

“matrix” list: a set of “vector”(s) vector: 1 dimensional object

16. ### vector in R in Excel     

               
17. ### vector         

           
18. ### vector         

     
19. ###  vector seq{base} Sequence Generation Description Generate regular sequences. seq

is a standard generic with a default method. … Usage seq(...) ## Default S3 method: seq(from = 1, to = 1, by = ((to - from)/(length.out - 1)), length.out = NULL, along.with = NULL, ...)
20. ### vector         

            
21. ### vector         

      
22. ### What is “data.frame” data.frame is a “list” looks like a

“matrix” list: a set of “vector”(s) vector: a one direction object ☑
23. ### list         

       
24. ### list         

           
25. ### list         

       
26. ### list         

                   
27. ### What is “data.frame” data.frame is a “list” looks like a

“matrix” list: a set of “vector”(s) vector: 1 dimentional object ☑ ☑
28. ### data.frame in R in Excel     

     
29. ### data.frame         >

df1 id value 1 a 11 2 b 12 3 c 13 4 d 14 5 e 15 > df1\$value[2:3] [1] 12 13 > df1[5, 2] [1] 15 row column
30. ### data.frame         

> df1 id value 1 a 11 2 b 12 3 c 13 4 d 14 5 e 15 > df1\$value[2:3] [1] 12 13 > df1[5, 2] [1] 15 row column column row
31. ### data.frame         >

summary(df1) id value a:1 Min. :11 b:1 1st Qu.:12 c:1 Median :13 d:1 Mean :13 e:1 3rd Qu.:14 Max. :15
32. ### data.frame         

> str(df1) 'data.frame': 5 obs. of 2 variables: \$ id : Factor w/ 5 levels "a","b","c","d",… \$ data: int 11 12 13 14 15
33. ### data.frame         >

str(df1) 'data.frame': 5 obs. of 2 variables: \$ id : Factor w/ 5 levels "a","b","c","d",… \$ value: int 11 12 13 14 15 row column

' ' ' ' "\$ "
35. ### data.frame  > head(iris)      

                            

37. ###  Boolean Algebra   George Boole 1815 - 1864

      # equal to # not equal to # or # and # is A in B? wikipedia
38. ### data.frame \$ ' row column row column > str(iris1) '

\$ ' \$ ' ' ' row column Boolean
39. ### \$ ( data.frame ) \$ ( ( ( \$ (

\$ \$ \$ ( ) ( ) ( ) \$ \$ \$ \$ \$ \$ ) ) )
40. ### in Excel Basic Technics to be Freedom in R in

R      

44. ### 1JQFBMHFCSB         

        {magrittr} dplyr  yutanihilation https://speakerdeck.com/yutannihilation/dplyrzai-ru-men-ji-ben-bian
45. ### {magrittr} 8@("* 6 ("* /=?.; 4 13  

 A("*B\$)&   -9 5:<1 R#+,'%!072>https://rlangradio.org/ 1JQFBMHFCSB 
46. ### {magrittr}       #  

                   #              1JQFBMHFCSB  
47. ### {magrittr} #        

    *OQVU 0VUQVU ① ② ③ 5IJOLJOHGMPX 4USVDUVSF 1JQFBMHFCSB  
48. ### {magrittr} #        

       *OQVU 0VUQVU 5IJOLJOHGMPX 3FBEJOHqPX 1JQFBMHFCSB  
49. ### {magrittr} #        

                */ 065 5IJOLJOH 4USVDUVSF 1JQFBMHFCSB 
50. ### {magrittr} #        

                  */ 065 5IJOLJOH 3FBEJOH 1JQFBMHFCSB 
51. ### {magrittr} #        

                   1JQFBMHFCSB 
52. ### {magrittr} #     */ 065  

                     ① ② ③ */ 065 */ 065 5IJOLJOH 3FBEJOH 1JQFBMHFCSB  
53. ### {magrittr} #    536&*/ 5FNQPSBM065   

                   ① ② ③ 5FNQ*/ 5FNQ065 5FNQ065 536&065 5IJOLJOH 3FBEJOH 1JQFBMHFCSB  
54. ### {magrittr} #   536&*/     

                       536&065 5IJOLJOH 3FBEJOH 1JQFBMHFCSB 
55. ### {magrittr} #        

                  */ 065 1JQFBMHFCSB 
56. ### {magrittr} #        

                   */ 065 1JQFBMHFCSB 
57. ### {magrittr} #        

                        */ 065 EPU 1JQFBMHFCSB 
58. ###          

      {magrittr} ͜Ε 1JQFBMHFCSB 
59. ### {magrittr}         

         “Passive” writing “Active” writing B AF   A F B 1JQFBMHFCSB  
60. ### {magrittr} " ( (. \$ (" ( "(") ) (

( \$ ) , (" ) ' % % \$ ' " % \$ % % \$ " % \$ ' " ) ( , ) ) ) ) ( "(") 1JQFBMHFCSB
61. ### {magrittr} %\$ 0 " \$,, \$ \$ \$' , ,

( ( . \$ % ) % '", ' ) % \$ , ' , % '", ' , % \$ , ' ) \$ ,( / % . % ,( \$', 1JQFBMHFCSB
62. ### {magrittr} * 0"06 ,"(0*220 *0*1 0\$., 120 *12 . 1%

4 -3, 0.2"2*.- -3, "220 %*,-", 1 *12 . \$)0 " -(2) " *%2) \$)0 \$ -2 0 ", % -3, "220 -", 1 \$)0 " -(2) 1\$" .(* 5 -3, 1JQFBMHFCSB

67. ### Basic Technics to be Freedom in R Pipe algebra Verb

functions data.frame
68. ###          

 # add column # select column # select row # arrange row # summary of values # fusion two dfs {dplyr} WFSCT WFSCGVODUJPOT
69. ### It (dplyr) provides simple “verbs” to help you translate your

thoughts into code. functions that correspond to the most common data manipulation tasks Introduction to dplyr https://cran.r-project.org/web/packages/dplyr/vignettes/dplyr.html WFSCT {dplyr}
70. ### dplyr - ,/  #0'"   (! \$* %.

1) (+) Introduction to dplyr https://cran.r-project.org/web/packages/dplyr/vignettes/dplyr.html WFSCT {dplyr}  &/
71. ### WFSCT S V O C M    

(, , etc)   
72. ### WFSCT S V O C M    

{dplyr}verb

74. ###          

  # add column # select column # select row # arrange row # summary of values # fusion two dfs {dplyr} WFSCT WFSCGVODUJPOT

76. ### %\$ 0 )%0 \$ \$ , , ' (/ ,

, ( ( . \$ % ) % '", ' ) % \$ , ' , % '", ' , % \$ , ' ) \$ ,( / % . % ,( \$', WFSCT {dplyr}
77. ### %\$ * *0 )%0* \$*\$ , , '*(/ *( '

, * ( ( . *\$ % ) % ' , ' ) % \$ , ' , % ' , ' , % \$ , ' ) \$ ,(* / % . % 1 ,( 2 ' WFSCT {dplyr} over write

79. ### \$ \$) )\$ \$ % % \$ % ( \$

% ' ' WFSCT {dplyr}

81. ### WFSCT {dplyr} # Select help functions    

              https://kazutan.github.io/blog/2017/04/dplyr-select-memo/ dplyr::selectkazutan
82. ###          

  #  #  #  #   #  #   {dplyr} WFSCT WFSCؔ਺܈

84. ###          

WFSCT {dplyr} 'data.frame': 50 obs. of 5 variables: \$ Sepal.Length: num 7 6.4 6.9 5.5 6.5 5.7 6.3 ... \$ Sepal.Width : num 3.2 3.2 3.1 2.3 2.8 2.8 ... \$ Petal.Length: num 4.7 4.5 4.9 4 4.6 4.5 4.7 ... \$ Petal.Width : num 1.4 1.5 1.5 1.3 1.5 1.3 ... \$ Species : Factor w/ 3 levels "setosa","versicolor",..: 2 2 2 2 2 2 2 2 2 2 ...
85. ###          

WFSCT {dplyr} NSE (Non-Standard Evaluation) 'data.frame': 50 obs. of 5 variables: \$ Sepal.Length: num 7 6.4 6.9 5.5 6.5 5.7 6.3 ... \$ Sepal.Width : num 3.2 3.2 3.1 2.3 2.8 2.8 ... \$ Petal.Length: num 4.7 4.5 4.9 4 4.6 4.5 4.7 ... \$ Petal.Width : num 1.4 1.5 1.5 1.3 1.5 1.3 ... \$ Species : Factor w/ 3 levels "setosa","versicolor",..: 2 2 2 2 2 2 2 2 2 2 ...
86. ###      /4&ͷ࿩ NSE (Non-Standard Evaluation) 

     SE (Standard Evaluation) http://dplyr.tidyverse.org/articles/programming.html Programming with dplyr
87. ###      /4&ͷ࿩ NSE  df 

  SQL   http://dplyr.tidyverse.org/articles/programming.html Programming with dplyr      
88. ###      /4&ͷ࿩ NSE   

    http://dplyr.tidyverse.org/articles/programming.html Programming with dplyr \$  " (!&)  (  # %)+* # verb (' ) # noun (' )
89. ###         /4&ͷ࿩ Because

of NSE.. http://dplyr.tidyverse.org/articles/programming.html Programming with dplyr        This do NOT work There is No “my_var” column in df
90. ### /4&ͷ࿩         

       dplyrTidyval  https://speakerdeck.com/yutannihilation/dplyrzai-ru-men-tidyevalbian dplyrTidyval yutanihilation
91. ### /4&ͷ࿩         

   %  dplyr +,Tidyval)-!' https://speakerdeck.com/yutannihilation/dplyrzai-ru-men-tidyevalbian "*#  . . *\$&( dplyr +,Tidyval)-yutanihilation
92. ###          

 #  #  #  #   #  #   {dplyr} WFSCT WFSCؔ਺܈
93. ### WFSCT {dplyr}   #     

                

95. ### WFSCT {dplyr}        

      #                    

98. ### Basic Technics to be Freedom in R Pipe algebra Verb

functions data.frame  mutate, select, filter, arrange, summaries, join
99. ### (SBNNBSPGEBUBNBOJQVMBUJPO By constraining your options, it helps you think about

your data manipulation challenges. Introduction to dplyr https://cran.r-project.org/web/packages/dplyr/vignettes/dplyr.html
100. ### ("% )  &#   \$ * !'+ Introduction

to dplyr https://cran.r-project.org/web/packages/dplyr/vignettes/dplyr.html   !' (SBNNBSPGEBUBNBOJQVMBUJPO
101. ###          И

́ горь Ф Страви́нский        

103. None