68th Tokyo.R Beginner session1

68th Tokyo.R Beginner session1

第68回Tokyo.Rの初心者セッション1:data import/exportのスライドです。

8284465a94bbdf1ea82cf1a67d55f447?s=128

kilometer

March 03, 2018
Tweet

Transcript

  1.     @kilometer BeginneR Session 1 -- Data

    Import / Export -- 2018.03.03 at Shiodome
  2. Who 

  3. Who   @kilometer  Postdoc (Ph.D engineering)  

    Animal Behavior Neuro Imaging Medical Engineering R ~ 10 years?  : 
  4. BeginneR Session

  5. 

  6. 

  7. Before After BeginneR Session  

  8. Input Output Today’s talk ? ? Table data Image data

    Other formats Introduction Summary
  9. !   #      $"

         $    $    
  10. #  %       &$

      ! & ! &  "       
  11.    !    "  

      "  "   
  12.    !    "  

      "  "   
  13. Input Output Do NOT start from here

  14. Input Output Do NOT start from here Whatever …

  15. Input Output Do NOT start from here Whatever … 1

    2 3
  16. Input Output Today’s talk ? ?

  17. Integrated Development Environment RStudio https://www.rstudio.com/ !

  18. Integrated Development Environment RStudio https://www.rstudio.com/

  19. RStudio

  20. Projects RStudio

  21. RStudio > Project .H21474836474<: G RStudio 7@ ,R&-%("#+!')0FC ,')JA!3? ,')6=!("#+!3<

    RStudio!E1  ฤू్தͷ಺༰Λอ࣋  D5921474836472R*-$-QOL!;8/ BI >   34UVEJPͬͯͳΜͩʁ 1SPKFDUͬͯͳΜͩ !XBLVUFLB https://qiita.com/wakuteka/items/9599bb0a8985d98928d7
  22. RStudio > Project R   +(  .'"& 

    #%"$ RStudio)!  *- , #%"&   34UVEJPͬͯͳΜͩʁ 1SPKFDUͬͯͳΜͩ !XBLVUFLB https://qiita.com/wakuteka/items/9599bb0a8985d98928d7
  23. File > New Project… > New Directory > New Project

    hogehoge
  24. hogehoge ~/Documents/R hogehoge.Rproj .Rproj.user Project Root Directory Double click!! .RData

    .Rhistory Auto saved project information Open project New!!
  25. ~/Documents/R project1 project2 project3 project4

  26. Input Output Today’s talk ? ? Table data Image data

    Other formats Summary Introduction
  27. Table format data Table data Image data Other formats Introduction

    Summary
  28. Table format data Comma-separated values (.csv) Tab-separated values (.tsv) Space-SV

    Semicolon-SV … Delimiter-separated values or Character-SV
  29.        Import Table format

    data object assignment operator file path function
  30.        Import Table format

    data object assignment operator file path function
  31. ~/Documents/ import.txt  data      

               or 1. set working directory 2. then use relative path Method②: use absolute path Method ① Import Table format data
  32. # # Method②: use absolute path Method ①: setwd –

    relative path " # or
  33. prj ~/Documents/R prj.Rproj import.txt Default working directory (project root) 

          can use relative path without  
  34.      Import Table format data

  35.      Import Table format data 

  36. ) ! ( ) ! ! ( ) ∖ #

    " !( !! ! (( # ! (( # ! (( # " ( ! # " ( ( ( () # ( ( ) ( # () # ( ! ! (( ( # ( ( # " ( !! ! # ! # ( ( () ) ! # ! # ( ( "" #) !! ( ( ! ( () # ( ( ) ( !) () # ( ( ) ( ! # # # # # # # ) ,) ( ! Import Table format data
  37. ) ! ( ) ! ! ( ) ∖ #

    " !( !! ! (( # ! (( # ! (( # " ( ! # " ( ( ( () # ( ( ) ( # () # ( ! ! (( ( # ( ( # " ( !! ! # ! # ( ( () ) ! # ! # ( ( "" #) !! ( ( ! ( () # ( ( ) ( !) () # ( ( ) ( ! # # # # # # # ) ,) ( ! Import Table format data
  38.   Usage read.table(file, skip = 0, header = FALSE,

    nrows = -1, row.names, fileEncoding = "") Import Table format data
  39. cf. R-Tips: 40.     http://cse.naro.affrc.go.jp/takezawa/r-tips/r/40.html  

                  Import Table format data
  40. " " " " " cf. R-Tips: 40.  

      http://cse.naro.affrc.go.jp/takezawa/r-tips/r/40.html Import Table format data
  41. " " " " " cf. R-Tips: 40.  

      http://cse.naro.affrc.go.jp/takezawa/r-tips/r/40.html Import Table format data
  42. " " " " " cf. R-Tips: 40.  

      http://cse.naro.affrc.go.jp/takezawa/r-tips/r/40.html Import Table format data
  43. " " " " " cf. R-Tips: 40.  

      http://cse.naro.affrc.go.jp/takezawa/r-tips/r/40.html Import Table format data
  44. " " " " " cf. R-Tips: 40.  

    # $ http://cse.naro.affrc.go.jp/takezawa/r-tips/r/40.html Import Table format data # &_"# $ # " # "/!  # %"
  45. " " " " " cf. R-Tips: 40.  

    # $ http://cse.naro.affrc.go.jp/takezawa/r-tips/r/40.html Import Table format data # &_"# $ # " # "/!  # %"
  46. 67  1 @y__mattu https://github.com/ymattu/TokyoR67 Import Table format data

  47.          

      ∖        Import Table format data Wrap
  48.      Import Table format data 

    Wrappers
  49.      Import Table format data 

    Wrappers
  50. Package … {utils} Package {base} Package

  51. Package Package Package Package Package Package Package Package Package Package

    Package Package Package Package Package
  52. packages 

  53. cf. http://rpkg.gepuro.net/ cf. https://cran.r-project.org/web/packages/ at 2018.02.20

  54. Package Default pkgs Package Package Package CRAN Guithub Package Package

    Package Package Package Package Package Package       
  55.      Import Table format data Default

    installed pkg (optional) Function     Install REQUIRED
  56. Import Table format data List of installed packages

  57. Import Table format data      

     Installation (from CRAN)     Usage          or
  58. Import Table format data Global environment # Attach {data.table}

  59. Import Table format data      

            Fast!!! Flexible!!! Need installation Should specify: data.table =FALSE Automatic!!! Simple!!!
  60.          

       object file path Export Table format data Wrapper
  61. Input Output Today’s talk ? ? Table data Image data

    Other formats Summary Introduction
  62. Image data Table data Image data Other formats Summary Introduction

  63. Export image data ?

  64. Export image data Use Graphic Device ready graphic device close

    graphic device draw graph(s) plotting functions High-level Low-level Interactive Basic Graphics in R http://bcb.dfci.harvard.edu/~aedin/courses/BiocDec2011/2.Plotting.pdf
  65. Export image data Use Graphic Device ready close draw 

             High-level plotting function
  66. hogehoge ~/Documents/R hogehoge.Rproj hoge.png New!!

  67. Export image data Graphic Devices in

  68. Export image data Graphic Devices in    

                          
  69.   ready graphic device close graphic device draw graph(s)

    Image data processing Import & Export image        processing
  70.   Import image data     

      
  71.   Import image data     

      
  72.   Import image data     

          
  73.   Import image data     

          
  74. Import image data       

        Export image data       # not CRAN pkg       # low googlability !
  75. Import image data       

        Export image data       # not CRAN pkg       # low googlability !
  76. None
  77. None
  78. None
  79. Salvador Dalí 1904-1989 profile of time wikipedia

  80. http://seekr.jp/

  81. None
  82. None
  83. Input Output Today’s talk ? ? Table data Image data

    Other formats Summary Introduction
  84. Table data Image data Other formats Other formats Summary Introduction

  85. .xls or .xlsx       GJMFQBUI

     TIFFUOBNFPS/P
  86. .json     Wrap    

    Wrap     
  87.    .wav or .mp3    

        
  88. .sas or .dta or .sav SAS Stata SPSS  

                      
  89.  Table data Image data Other formats Summary Introduction

  90. Input Output Do NOT start from here Whatever … 1

    2 3
  91. Data Import / Export ? ?

  92. packages 

  93. Data Import / Export ? ?    

                       packages
  94. ~/Documents/R project1 project2 project3 project4

  95. Before After BeginneR Session   ?

  96. ! KMT©

  97. KMT©