SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Downloaden Sie, um offline zu lesen
Stat405
Statistical computing & graphics


        Hadley Wickham
1. Introductions
2. Syllabus
3. Introduction to linux
4. Introduction to R
5. Basic graphics
HE LL O
 my name is




Hadley
had.co.nz/stat405
(if you can’t remember just google stat405)



   hadley@rice.edu
About me

From New Zealand
Divisional advisor for McMurtry
Major advisor for statistics
Syllabus
Introduction to linux
Essential tools
The terminal to run R. gedit to edit your R
code.
To load the terminal, right-click on the
desktop.
To load R, type R in the terminal. To load
gedit, type gedit & in the terminal (the &
tells it to run separately). To open a file in
gedit, type gedit filename &
Setup

Work through the instructions at http://
had.co.nz/stat405/linux.html.
I’ll circulate and make sure everyone gets
set up right.
Terminal essentials
Mouse select = Copy
Middle button = Paste
Ctrl + A = home
Ctrl + D = end
Alt + tab = change applications
Press tab to complete file names
Introduction to R
Learning a new
language is hard!
Scatterplot basics
install.packages("ggplot2")
library(ggplot2)

?mpg
head(mpg)
str(mpg)
summary(mpg)

qplot(displ, hwy, data = mpg)
Scatterplot basics
install.packages("ggplot2")
library(ggplot2)

?mpg
head(mpg)
str(mpg)
                   Always explicitly
summary(mpg)       specify the data

qplot(displ, hwy, data = mpg)
●




                          ●

             40


                      ●
                      ●

             35       ●
                      ●
                  ●   ●
                  ●                       ●
                              ●       ●●

             30       ●       ●       ●
                  ●   ●       ●   ●   ●●                              ●
       hwy




                              ●           ●                   ●       ●        ●
                              ●   ●   ●●                  ●   ●       ●        ●
                      ●       ●   ●   ●●          ●   ●●              ●●       ●    ●                                    ●               ●

             25       ●                   ●       ●   ●●              ●        ●                                ●                        ●
                                      ●●      ●●      ●       ●                     ●                                                            ●
                                          ●       ●                            ●    ●   ●       ●                        ●
                                              ●       ●       ●                ●                ●
                                                                               ●                ●

             20                               ●                                     ●                           ●●
                                                                  ●        ●        ●           ●●              ●
                                                                           ●        ●   ●   ●                       ●   ●●
                                                              ●●                   ●●   ●       ●●      ●   ●       ●    ●       ●           ●
                                                                                                ●●          ●       ●

             15                                                                     ●           ●●          ●●●          ●   ●
                                                                                                                ●                    ●


                                                                                                    ●



                              2                       3                             4                   5                        6               7
qplot(displ, hwy, data = mpg)
                          displ
Additional variables

Can display additional variables with
aesthetics (like shape, colour, size) or
facetting (small multiples displaying
different subsets)
●




                          ●

             40


                      ●
                      ●

             35       ●
                      ●
                  ● ●                                                                                                              class
                  ●                   ●
                              ●   ●●
                                                                                                                                    ●   2seater
             30       ● ●         ●                                                                                                 ●   compact
                  ● ● ● ● ●●                                    ●
                                                                                                                                    ●   midsize
       hwy




                              ●       ●                 ● ●             ●
                              ● ● ●●                  ● ● ●             ●                                                           ●   minivan
                      ● ● ● ●●                ● ●●              ●● ● ●                                   ●             ●

             25       ●               ●       ● ●●              ●       ●                         ●                    ●            ●   pickup
                                  ●● ●● ●               ●                    ●                                                 ●
                                      ●       ●                         ● ● ●        ●                   ●
                                                                                                                                    ●   subcompact
                                          ●       ●     ●               ●            ●                                              ●   suv
                                                                        ●            ●

             20                           ●                                  ●                    ●●
                                                            ●       ●        ●       ●●           ●
                                                                    ●        ● ● ●                    ● ●●
                                                        ●●                  ●● ●     ●●      ● ● ●       ●     ●           ●
                                                                                     ●●          ● ●

             15                                                              ●       ●●          ●●●     ● ●
                                                                                                  ●                ●


                                                                                         ●



                          2                       3                         4                5               6                 7
qplot(displ, hwy, colour = class, data = mpg)
                      displ
●




                          ●

             40


                      ●
                      ●

             35       ●
                      ●
                  ● ●                                                                                                              class
                  ●                   ●
                              ●   ●●
                                                                                                                                    ●   2seater
             30       ● ●         ●                                                                                                 ●   compact
                  ● ● ● ● ●●                                    ●
                                                                                                                                    ●   midsize
       hwy




                              ●       ●                 ● ●             ●
                              ● ● ●●                  ● ● ●             ●                                                           ●   minivan
                      ● ● ● ●●                ● ●●              ●● ● ●                                   ●             ●

             25       ●               ●       ● ●●              ●       ●                         ●                    ●            ●   pickup
                                  ●● ●● ●               ●                    ●                                                 ●
                                      ●       ●                         ● ● ●        ●                   ●
                                                                                                                                    ●   subcompact
                                          ●       ●     ●               ●            ●                                              ●   suv
                                                                        ●            ●

             20                           ●                                  ●                    ●●
                                                            ●       ●        ●       ●●           ●
                                                                    ●        ● ● ●                    ● ●●                       Legend chosen and
                                                                                                                               displayed automatically.
                                                        ●●                  ●● ●     ●●      ● ● ●       ●     ●           ●
                                                                                     ●●          ● ●

             15                                                              ●       ●●          ●●●     ● ●
                                                                                                  ●                ●


                                                                                         ●



                          2                       3                         4                5               6                 7
qplot(displ, hwy, colour = class, data = mpg)
                      displ
Your turn
Experiment with colour, size, and shape
aesthetics.
What’s the difference between discrete or
continuous variables?
What happens when you combine
multiple aesthetics?
Discrete        Continuous

          Rainbow of       Gradient from
Colour
           colours          red to blue

                           Linear mapping
          Discrete size
 Size                      between radius
             steps
                              and value

         Different shape
Shape                       Doesn’t work
             for each
Faceting

Small multiples displaying different
subsets of the data.
Useful for exploring conditional
relationships. Useful for large data.
Your turn
qplot(displ, hwy, data = mpg) +
facet_grid(. ~ cyl)
qplot(displ, hwy, data = mpg) +
facet_grid(drv ~ .)
qplot(displ, hwy, data = mpg) +
facet_grid(drv ~ cyl)
qplot(displ, hwy, data = mpg) +
facet_wrap(~ class)
Summary

facet_grid(): 2d grid, rows ~ cols, . for
no split
facet_wrap(): 1d ribbon wrapped into 2d
Aside: workflow

Keep a copy of the slides open so that
you can copy and paste the code.
For complicated commands, write them
in gedit and then copy and paste.
What’s the                                                                               ●   ●




            40   problem with                                                                    ●




                 this plot?                                                     ●   ●
                                                                                             ●


            35                                                                           ●
                                                                                         ●
                                                                                ●            ●
                                                                            ●   ●   ●
                                                               ●    ●   ●   ●

            30                                                      ●   ●       ●
                                                       ●   ●   ●    ●   ●   ●
      hwy




                                                       ●   ●   ●
                                                   ●   ●   ●   ●    ●
                                               ●   ●   ●   ●   ●    ●

            25                            ●    ●   ●   ●   ●   ●
                                          ●    ●   ●   ●
                                          ●    ●       ●
                                          ●    ●   ●
                                          ●

            20                        ●   ●    ●
                                  ●   ●   ●
                              ●   ●   ●   ●
                          ●   ●   ●   ●   ●
                          ●   ●   ●

            15            ●
                          ●


                 ●



                     10                   15                   20                   25               30       35
qplot(cty, hwy, data = mpg)
                       cty
●   ●




                                                                                              ●

            40


                                                                                          ●
                                                                                ●
                                                                            ●
                                                                                     ●●
            35
                                                                                      ●
                                                                           ●              ●
                                                                       ●    ● ●
                                                                             ●
                                                           ●      ●
                                                                 ●● ● ●
                                                                   ●
                                                                           ●
            30                                                  ●
                                                                   ●
                                                                     ●
                                                    ●
                                                    ●●          ●● ● ●
                                                                 ●●
                                                                  ●
                                                                 ●●
                                                          ● ● ●● ●●    ●
                                                     ●     ●● ●
      hwy




                                                        ●
                                                        ●●     ●
                                                 ● ●● ●● ●    ● ●
                                                          ● ●  ● ●
                                                      ● ● ●
                                               ● ● ●● ●● ●
                                                      ● ●
                                                      ● ●         ●
                                            ●● ●     ●● ●
                                               ●● ● ● ●
                                                      ● ●      ●
                                       ● ●         ● ●● ●●
                                                         ●
            25                             ● ●● ● ●     ●    ●
                                        ●      ● ●
                                              ● ●● ●
                                                  ●
                                        ●        ●
                                                 ●● ●
                                          ●● ●
                                             ●
                                         ● ●
                                          ●        ●●
                                          ● ●
                                           ●
                                              ● ●
                                        ●
                                          ●
                                             ●
            20                     ●● ● ● ●●
                                    ●
                                    ●    ● ●
                                 ●● ●    ●●
                                          ●
                              ● ●● ●  ● ●
                                       ●
                           ● ● ●● ● ●
                           ● ●
                                 ●
                        ●   ● ● ● ●● ● ●
                        ●
                       ●●      ●●●●●● ●
                               ●
                               ●●     ●
                        ●      ● ● ●●●
                                  ●
                        ● ● ●●● ●
                         ●
            15         ●●
                       ●●
                       ●●
                        ●
                        ●
                       ●
                        ●

                 ●
                 ●●
                 ●●



                      10               15                 20                    25                30       35
qplot(cty, hwy, data = mpg, geom = "jitter")
                       cty
●   ●




                                                                                              ●

            40


                                                                                          ●
                                                                                ●
                                                                            ●
                                                                                     ●●
            35
                                                                                      ●
                                                                           ●              ●
                                                                       ●    ● ●
                                                                             ●
                                                           ●      ●
                                                                 ●● ● ●
                                                                   ●
                                                                           ●
            30                                                  ●
                                                                   ●
                                                                     ●
                                                    ●
                                                    ●●          ●● ● ●
                                                                 ●●
                                                                  ●
                                                                 ●●
                                                          ● ● ●● ●●    ●
                                                     ●     ●● ●
      hwy




                                                        ●
                                                        ●●     ●
                                                 ● ●● ●● ●    ● ●
                                                          ● ●  ● ●
                                                      ● ● ●
                                               ● ● ●● ●● ●
                                                      ● ●
                                                      ● ●         ●
                                            ●● ●     ●● ●
                                               ●● ● ● ●
                                                      ● ●      ●
                                       ● ●         ● ●● ●●
                                                         ●
            25                             ● ●● ● ●     ●    ●
                                        ●      ● ●
                                              ● ●● ●
                                                  ●
                                        ●        ●
                                                 ●● ●
                                          ●● ●
                                             ●
                                         ● ●
                                          ●        ●●
                                          ● ●
                                           ●
                                              ● ●
                                        ●
                                          ●
                                             ●
            20                     ●● ● ● ●●
                                    ●
                                    ●    ● ●
                                 ●● ●    ●●
                                          ●
                              ● ●● ●  ● ●
                                       ●
                           ● ● ●● ● ●
                           ● ●
                                 ●
                        ●   ● ● ● ●● ● ●
                        ●
                       ●●      ●●●●●● ●
                               ●
                               ●●     ●
                        ●      ● ● ●●●
                                  ●
                        ● ● ●●● ●
                         ●
            15         ●●
                       ●●
                       ●●
                        ●
                        ●
                       ●
                        ●

                 ●
                 ●●
                                                                                      geom controls
                 ●●
                                                                                      “type” of plot
                      10               15                 20                    25                30       35
qplot(cty, hwy, data = mpg, geom = "jitter")
                       cty
●                                       ●




                                                                ●

      40


                        ●
                                                                ●

      35                ●
                                                                ●
                        ●                                       ●
                                  ●                             ●
                        ●         ●

      30                ●         ●
                        ●         ●                             ●
hwy




                        ●         ●                             ●
                        ●         ●                             ●         ●
              ●         ●         ●                             ●         ●

      25      ●         ●         ●                             ●         ●
              ●         ●         ●         ●                   ●         ●
              ●         ●         ●         ●                   ●         ●
                                            ●        ●          ●         ●
                                            ●                   ●

      20                                             ●          ●         ●
                                                     ●                    ●
                                                     ●                    ●
                                            ●        ●                    ●
                                                     ●                    ●

      15                                             ●                    ●
                                                                          ●


                                                     ●                    ●



           2seater   compact   midsize   minivan   pickup   subcompact   suv
qplot(class, hwy, data = mpg)
                          class
How could     ●                                       ●




           we improve
                                                                 ●

      40


           this plot?    ●
                                                                 ●

      35                 ●
                                                                 ●



           Brainstorm    ●


                         ●
                                   ●
                                   ●
                                                                 ●
                                                                 ●


      30
           for 1 minute.
                         ●         ●
                         ●         ●                             ●
hwy




                         ●         ●                             ●
                         ●         ●                             ●         ●
               ●         ●         ●                             ●         ●

      25       ●         ●         ●                             ●         ●
               ●         ●         ●         ●                   ●         ●
               ●         ●         ●         ●                   ●         ●
                                             ●        ●          ●         ●
                                             ●                   ●

      20                                              ●          ●         ●
                                                      ●                    ●
                                                      ●                    ●
                                             ●        ●                    ●
                                                      ●                    ●

      15                                              ●                    ●
                                                                           ●


                                                      ●                    ●



            2seater   compact   midsize   minivan   pickup   subcompact   suv
qplot(class, hwy, data = mpg)
                          class
●           ●




                                                                     ●

      40


                                                                                 ●
                                                                     ●

      35                                                                         ●
                                                                     ●
                                                                     ●           ●
                                                          ●          ●
                                                          ●                      ●

      30                                                  ●                      ●
                                                          ●          ●           ●
hwy




                                                          ●          ●           ●
                     ●                                    ●          ●           ●
                     ●                      ●             ●          ●           ●

      25             ●                      ●             ●          ●           ●
                     ●       ●              ●             ●          ●           ●
                     ●       ●              ●             ●          ●           ●
             ●       ●       ●                                       ●
                             ●                                       ●

      20     ●       ●                                               ●
             ●       ●
             ●       ●
             ●       ●       ●
             ●       ●

      15     ●       ●
                     ●


             ●       ●



           pickup   suv   minivan        2seater       midsize   subcompact   compact
                                 reorder(class, hwy)
●           ●




                                                                 ●

      40


                                                                             ●
                                                                 ●

      35                                                                     ●
                                                                 ●
                                                                 ●           ●
                                                      ●          ●
                                                      ●                      ●

      30                                              ●                      ●
                                                      ●          ●           ●
hwy




                                                      ●          ●           ●
                       ●                              ●          ●           ●
                       ●                    ●         ●          ●           ●

      25               ●                    ●         ●          ●           ●
                       ●          ●         ●         ●          ●           ●
                       ●          ●         ●         ●          ●           ●
             ●         ●          ●                              ●
                                  ●                              ●

      20     ●         ●                                         ●
             ●         ●
             ●         ●
             ●         ●          ●
             ●         ●

      15     ●         ●

           Incredibly useful
                       ●


             ●
              technique!
                       ●



           pickup     suv      minivan   2seater   midsize   subcompact   compact
qplot(reorder(class, hwy), hwy, data = mpg)
                      reorder(class, hwy)
●                            ●




                                                                                                                                                                ●

      40

                                                                                                                                                                            ●

                                                                                                                                                    ●
                                                                                                                                   ●
                                                                                                                                                                                 ●    ●
      35
                                                                                                                                           ●
                                                                                                                                                                        ●
                                                                                                                                                            ●
                                                                                                                 ●                 ●       ●
                                                                                                            ●                                           ●
                                                                                                            ●                                                                   ●          ●
                                                                                                             ●       ●                                                           ●
                                                                                                                                                                        ●
      30                                                                                                              ●   ●                                                               ●

                                                                                                                  ● ● ●       ●●           ●       ●●                  ● ● ● ●
                                                                                                                                                                       ●
                                                                                                                                                                    ● ●●
                                                                                                                                                                     ●
                                                                                                                                   ●                        ●       ●●  ●
                                                                                                                      ●                                     ●             ●
                                                                                                                 ● ● ●                 ●
hwy




                                                                                                                    ●                                               ●                ● ●
                                                                                                                                                                                     ● ●
                                                            ●                                                ● ●     ●●                                         ●   ●
                                                ●                                               ●             ●● ●
                                                                                                              ●        ●
                                                                                                                         ●         ●●              ●●                   ●        ●
                                                                                                    ●       ● ●
                                                                                                            ● ●
                                                                                                            ●         ●●●          ● ●                                   ●        ●     ●●
                                                                                                            ●                                               ●                          ●
                                                                                                                                           ●                            ● ●
      25                                    ●       ●                                     ●                          ● ●●
                                                                                                                                                                                 ●●
                                                                                                                                                                                 ●
                                                                                                                                                                                       ●
                                                                                                                                                                                       ●
                                        ●                            ●                ●                                                    ●                 ●              ●    ●
                                                                                                        ●                              ●
                                                                             ●●                              ●                                              ●
                                                                                                    ●                ●
                                                        ●                         ●                                                    ●                                               ●
                                                                 ●
                           ●                    ●                                 ●                                                                     ●
                                                                         ●        ●                                                                      ●
                                                                 ●
                                                                                                                                               ●
               ●       ●
      20                   ●
                                   ●     ●
                                       ● ●          ●●      ●                                                                                           ●
             ●                                      ●●      ●●
           ●●      ●                ●                       ●●
                                          ●      ●
                               ●      ●
             ●                        ●● ● ●●●
              ●     ●
                    ●    ●         ● ● ● ●●
                ●  ●     ●         ●●● ●     ●     ●                     ●
            ● ● ●
             ●                         ●● ●     ●  ●
            ●● ●        ●                      ● ●
                  ●
           ●                          ● ●
      15   ● ●        ●              ● ●        ● ●
                                         ●
                                         ●


           ●           ●   ●                 ●          ●




               pickup                        suv                     minivan                  2seater            midsize           subcompact                           compact
qplot(reorder(class, hwy),reorder(class, hwy) = mpg, geom = "jitter")
                            hwy, data
●           ●




                                                            ●

      40


                                                                        ●


      35                                                                ●




      30
hwy




                     ●
                     ●

      25             ●
                     ●
                     ●
             ●


      20


                             ●


      15


             ●       ●



           pickup   suv   minivan   2seater   midsize   subcompact   compact
qplot(reorder(class, hwy), hwy, data hwy)mpg, geom = "boxplot")
                           reorder(class, =
●
                                                                                                                                               ●                            ●
                                                                                                                                                                            ●




                                                                                                                                               ●           ●

      40


                                                                                                                                                                            ● ●
                                                                                                                                           ● ●

      35                                                                                                                                                           ●        ● ●
                                                                                                                                               ●
                                                                                                                                                                                   ●
                                                                                                                                                           ●
                                                                                                                        ●             ● ● ●
                                                                                                       ●                                                           ●                 ●
                                                                                                               ●        ●●                                                       ●
      30                                                                                               ●           ●    ●                                              ●
                                                                                                                                                                      ●●
                                                                                                                                                                                ●●
                                                                                                                        ●
                                                                                                                       ● ●                                 ●                      ●●
                                                                                                                                  ●   ●●●                           ●● ●●       ● ●●
                                                                                                                           ●
                                                                                                               ●       ●               ●                           ●
hwy




                                                                                                                        ●
                                                                                                                        ●                              ●
                                                                                                       ●                 ●             ●                                    ●● ●●
                                                 ● ●                                                                                                               ●           ●
                                                                                                           ●     ●            ●                                                 ●
                                         ●                                                             ●        ●
                                                                                                                ● ●          ●    ●   ●●●                  ●              ●●
                                                 ●                                             ●               ●●            ●
                                                                                                                            ●●                                        ●      ●●
                                                                                                                                                                              ●
                                                                                       ●                   ●    ●
                                                                                                                ●           ●       ●   ●●                              ●
                                                                                                   ●
      25                             ●           ●         ●                                               ●                ●                                        ● ●● ●
                                                                                                                             ●
                                                                                                                             ●                             ●       ●            ●
                                                 ●             ●                                   ●                              ●                ●
                                                                                                                                                   ●                         ●●
                                                               ●       ●   ●                                   ●                                       ●
                                                       ●                                                                                                             ●
                                     ●           ●                                         ●               ●                                       ●
                                                               ●                   ●
                   ●                                               ●
                   ●                             ●                 ●
                                                                                   ●                                                       ●           ●
                                                                                                                                                               ●
                                                                               ●
                           ●          ●
      20   ●       ●               ●● ●
                                    ●        ●
                                             ●                                                                                                 ●
                                            ●● ● ●●
           ●               ●● ●    ● ●       ●    ●
                            ●
                            ●          ●   ● ●  ●
                                         ●
                                         ●     ●
                       ●                ●      ●                       ●
           ● ●●
              ●     ● ●●           ●●●●● ● ● ●
                                     ●
                                      ● ●● ● ● ● ●
                                         ●                             ●
                ● ● ●                          ●
                 ●                     ●
            ●   ●
                ●    ●
                   ●                 ●       ●
      15    ●     ●    ●             ●        ●●           ●
                                             ●
                                             ●

                           ●             ●
               ●       ●                         ●
                                                 ●
                               ●



qplot(reorder(class,minivan
       pickup suv
                      hwy), 2seater data = subcompact
                                  hwy, midsize mpg,                                                                                                                    compact
  geom = c("jitter", "boxplot"))
                         reorder(class, hwy)
Your turn

Read the help for reorder. Redraw the
previously plots with class ordered by
median hwy.
How would you put the jittered points on
top of the boxplots?
Aside: coding strategy

At the end of each interactive session, you
want a summary of everything you did. Two
options:
1. Save everything you did with savehistory()
then remove the unimportant bits.
2. Build up the important bits as you go.
(this is how I work)

Weitere ähnliche Inhalte

Ähnlich wie 01 Intro

Over Visie, Missie En Strategie
Over Visie, Missie En StrategieOver Visie, Missie En Strategie
Over Visie, Missie En StrategieGuus Vos
 
About Vision, Mission And Strategy
About Vision, Mission And StrategyAbout Vision, Mission And Strategy
About Vision, Mission And StrategyGuus Vos
 
Modul mulus bahagian c sjk (modul murid)
Modul mulus bahagian c sjk (modul murid)Modul mulus bahagian c sjk (modul murid)
Modul mulus bahagian c sjk (modul murid)Anparasu
 
Modul mulus bahagian c sjk (modul guru)
Modul mulus bahagian c sjk (modul guru)Modul mulus bahagian c sjk (modul guru)
Modul mulus bahagian c sjk (modul guru)Anparasu
 
Modul mulus bahagian c sk (modul murid)
Modul mulus bahagian c sk (modul murid)Modul mulus bahagian c sk (modul murid)
Modul mulus bahagian c sk (modul murid)Anparasu
 
Modul mulus bahagian c sk (modul guru)
Modul mulus bahagian c sk (modul guru)Modul mulus bahagian c sk (modul guru)
Modul mulus bahagian c sk (modul guru)Anparasu
 
Los Angeles R users group - July 12 2011 - Part 1
Los Angeles R users group - July 12 2011 - Part 1Los Angeles R users group - July 12 2011 - Part 1
Los Angeles R users group - July 12 2011 - Part 1rusersla
 
Fairisle knitting
Fairisle knittingFairisle knitting
Fairisle knittingzafiro555
 
正誤表 p39
正誤表 p39正誤表 p39
正誤表 p39zafiro555
 
研修企画書11 12term voda-カヤック
研修企画書11 12term voda-カヤック研修企画書11 12term voda-カヤック
研修企画書11 12term voda-カヤックaiesecsfc_icx2011
 
How People Use Facebook -- And Why It Matters
How People Use Facebook -- And Why It MattersHow People Use Facebook -- And Why It Matters
How People Use Facebook -- And Why It MattersMat Morrison
 
研修企画書11-12term voda-カヤック
研修企画書11-12term voda-カヤック研修企画書11-12term voda-カヤック
研修企画書11-12term voda-カヤックaiesecsfc_icx2011
 

Ähnlich wie 01 Intro (20)

Over Visie, Missie En Strategie
Over Visie, Missie En StrategieOver Visie, Missie En Strategie
Over Visie, Missie En Strategie
 
About Vision, Mission And Strategy
About Vision, Mission And StrategyAbout Vision, Mission And Strategy
About Vision, Mission And Strategy
 
02 Large
02 Large02 Large
02 Large
 
02 large
02 large02 large
02 large
 
01 intro
01 intro01 intro
01 intro
 
Modul mulus bahagian c sjk (modul murid)
Modul mulus bahagian c sjk (modul murid)Modul mulus bahagian c sjk (modul murid)
Modul mulus bahagian c sjk (modul murid)
 
Modul mulus bahagian c sjk (modul guru)
Modul mulus bahagian c sjk (modul guru)Modul mulus bahagian c sjk (modul guru)
Modul mulus bahagian c sjk (modul guru)
 
Modul mulus bahagian c sk (modul murid)
Modul mulus bahagian c sk (modul murid)Modul mulus bahagian c sk (modul murid)
Modul mulus bahagian c sk (modul murid)
 
Modul mulus bahagian c sk (modul guru)
Modul mulus bahagian c sk (modul guru)Modul mulus bahagian c sk (modul guru)
Modul mulus bahagian c sk (modul guru)
 
13 Bivariate
13 Bivariate13 Bivariate
13 Bivariate
 
Los Angeles R users group - July 12 2011 - Part 1
Los Angeles R users group - July 12 2011 - Part 1Los Angeles R users group - July 12 2011 - Part 1
Los Angeles R users group - July 12 2011 - Part 1
 
Fairisle knitting
Fairisle knittingFairisle knitting
Fairisle knitting
 
正誤表 p39
正誤表 p39正誤表 p39
正誤表 p39
 
17 Sampling Dist
17 Sampling Dist17 Sampling Dist
17 Sampling Dist
 
08 Continuous
08 Continuous08 Continuous
08 Continuous
 
08 Continuous
08 Continuous08 Continuous
08 Continuous
 
研修企画書11 12term voda-カヤック
研修企画書11 12term voda-カヤック研修企画書11 12term voda-カヤック
研修企画書11 12term voda-カヤック
 
21 Ml
21 Ml21 Ml
21 Ml
 
How People Use Facebook -- And Why It Matters
How People Use Facebook -- And Why It MattersHow People Use Facebook -- And Why It Matters
How People Use Facebook -- And Why It Matters
 
研修企画書11-12term voda-カヤック
研修企画書11-12term voda-カヤック研修企画書11-12term voda-カヤック
研修企画書11-12term voda-カヤック
 

Mehr von Hadley Wickham (20)

27 development
27 development27 development
27 development
 
27 development
27 development27 development
27 development
 
24 modelling
24 modelling24 modelling
24 modelling
 
23 data-structures
23 data-structures23 data-structures
23 data-structures
 
Graphical inference
Graphical inferenceGraphical inference
Graphical inference
 
R packages
R packagesR packages
R packages
 
22 spam
22 spam22 spam
22 spam
 
21 spam
21 spam21 spam
21 spam
 
20 date-times
20 date-times20 date-times
20 date-times
 
19 tables
19 tables19 tables
19 tables
 
18 cleaning
18 cleaning18 cleaning
18 cleaning
 
16 critique
16 critique16 critique
16 critique
 
15 time-space
15 time-space15 time-space
15 time-space
 
13 case-study
13 case-study13 case-study
13 case-study
 
11 adv-manip
11 adv-manip11 adv-manip
11 adv-manip
 
11 adv-manip
11 adv-manip11 adv-manip
11 adv-manip
 
10 simulation
10 simulation10 simulation
10 simulation
 
10 simulation
10 simulation10 simulation
10 simulation
 
09 bootstrapping
09 bootstrapping09 bootstrapping
09 bootstrapping
 
08 functions
08 functions08 functions
08 functions
 

Kürzlich hochgeladen

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

01 Intro

  • 1. Stat405 Statistical computing & graphics Hadley Wickham
  • 2. 1. Introductions 2. Syllabus 3. Introduction to linux 4. Introduction to R 5. Basic graphics
  • 3. HE LL O my name is Hadley
  • 4. had.co.nz/stat405 (if you can’t remember just google stat405) hadley@rice.edu
  • 5. About me From New Zealand Divisional advisor for McMurtry Major advisor for statistics
  • 8. Essential tools The terminal to run R. gedit to edit your R code. To load the terminal, right-click on the desktop. To load R, type R in the terminal. To load gedit, type gedit & in the terminal (the & tells it to run separately). To open a file in gedit, type gedit filename &
  • 9. Setup Work through the instructions at http:// had.co.nz/stat405/linux.html. I’ll circulate and make sure everyone gets set up right.
  • 10. Terminal essentials Mouse select = Copy Middle button = Paste Ctrl + A = home Ctrl + D = end Alt + tab = change applications Press tab to complete file names
  • 14. Scatterplot basics install.packages("ggplot2") library(ggplot2) ?mpg head(mpg) str(mpg) Always explicitly summary(mpg) specify the data qplot(displ, hwy, data = mpg)
  • 15. ● 40 ● ● 35 ● ● ● ● ● ● ● ●● 30 ● ● ● ● ● ● ● ●● ● hwy ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ●● ● ●● ●● ● ● ● ● 25 ● ● ● ●● ● ● ● ● ●● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 20 ● ● ●● ● ● ● ●● ● ● ● ● ● ● ●● ●● ●● ● ●● ● ● ● ● ● ● ●● ● ● 15 ● ●● ●●● ● ● ● ● ● 2 3 4 5 6 7 qplot(displ, hwy, data = mpg) displ
  • 16. Additional variables Can display additional variables with aesthetics (like shape, colour, size) or facetting (small multiples displaying different subsets)
  • 17. ● 40 ● ● 35 ● ● ● ● class ● ● ● ●● ● 2seater 30 ● ● ● ● compact ● ● ● ● ●● ● ● midsize hwy ● ● ● ● ● ● ● ●● ● ● ● ● ● minivan ● ● ● ●● ● ●● ●● ● ● ● ● 25 ● ● ● ●● ● ● ● ● ● pickup ●● ●● ● ● ● ● ● ● ● ● ● ● ● ● subcompact ● ● ● ● ● ● suv ● ● 20 ● ● ●● ● ● ● ●● ● ● ● ● ● ● ●● ●● ●● ● ●● ● ● ● ● ● ● ●● ● ● 15 ● ●● ●●● ● ● ● ● ● 2 3 4 5 6 7 qplot(displ, hwy, colour = class, data = mpg) displ
  • 18. ● 40 ● ● 35 ● ● ● ● class ● ● ● ●● ● 2seater 30 ● ● ● ● compact ● ● ● ● ●● ● ● midsize hwy ● ● ● ● ● ● ● ●● ● ● ● ● ● minivan ● ● ● ●● ● ●● ●● ● ● ● ● 25 ● ● ● ●● ● ● ● ● ● pickup ●● ●● ● ● ● ● ● ● ● ● ● ● ● ● subcompact ● ● ● ● ● ● suv ● ● 20 ● ● ●● ● ● ● ●● ● ● ● ● ● ● ●● Legend chosen and displayed automatically. ●● ●● ● ●● ● ● ● ● ● ● ●● ● ● 15 ● ●● ●●● ● ● ● ● ● 2 3 4 5 6 7 qplot(displ, hwy, colour = class, data = mpg) displ
  • 19. Your turn Experiment with colour, size, and shape aesthetics. What’s the difference between discrete or continuous variables? What happens when you combine multiple aesthetics?
  • 20. Discrete Continuous Rainbow of Gradient from Colour colours red to blue Linear mapping Discrete size Size between radius steps and value Different shape Shape Doesn’t work for each
  • 21. Faceting Small multiples displaying different subsets of the data. Useful for exploring conditional relationships. Useful for large data.
  • 22. Your turn qplot(displ, hwy, data = mpg) + facet_grid(. ~ cyl) qplot(displ, hwy, data = mpg) + facet_grid(drv ~ .) qplot(displ, hwy, data = mpg) + facet_grid(drv ~ cyl) qplot(displ, hwy, data = mpg) + facet_wrap(~ class)
  • 23. Summary facet_grid(): 2d grid, rows ~ cols, . for no split facet_wrap(): 1d ribbon wrapped into 2d
  • 24. Aside: workflow Keep a copy of the slides open so that you can copy and paste the code. For complicated commands, write them in gedit and then copy and paste.
  • 25. What’s the ● ● 40 problem with ● this plot? ● ● ● 35 ● ● ● ● ● ● ● ● ● ● ● 30 ● ● ● ● ● ● ● ● ● hwy ● ● ● ● ● ● ● ● ● ● ● ● ● ● 25 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 20 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 15 ● ● ● 10 15 20 25 30 35 qplot(cty, hwy, data = mpg) cty
  • 26. ● ● 40 ● ● ● ●● 35 ● ● ● ● ● ● ● ● ● ●● ● ● ● ● 30 ● ● ● ● ●● ●● ● ● ●● ● ●● ● ● ●● ●● ● ● ●● ● hwy ● ●● ● ● ●● ●● ● ● ● ● ● ● ● ● ● ● ● ● ●● ●● ● ● ● ● ● ● ●● ● ●● ● ●● ● ● ● ● ● ● ● ● ● ●● ●● ● 25 ● ●● ● ● ● ● ● ● ● ● ●● ● ● ● ● ●● ● ●● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● 20 ●● ● ● ●● ● ● ● ● ●● ● ●● ● ● ●● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ●● ● ● ● ●● ●●●●●● ● ● ●● ● ● ● ● ●●● ● ● ● ●●● ● ● 15 ●● ●● ●● ● ● ● ● ● ●● ●● 10 15 20 25 30 35 qplot(cty, hwy, data = mpg, geom = "jitter") cty
  • 27. ● ● 40 ● ● ● ●● 35 ● ● ● ● ● ● ● ● ● ●● ● ● ● ● 30 ● ● ● ● ●● ●● ● ● ●● ● ●● ● ● ●● ●● ● ● ●● ● hwy ● ●● ● ● ●● ●● ● ● ● ● ● ● ● ● ● ● ● ● ●● ●● ● ● ● ● ● ● ●● ● ●● ● ●● ● ● ● ● ● ● ● ● ● ●● ●● ● 25 ● ●● ● ● ● ● ● ● ● ● ●● ● ● ● ● ●● ● ●● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● 20 ●● ● ● ●● ● ● ● ● ●● ● ●● ● ● ●● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ●● ● ● ● ●● ●●●●●● ● ● ●● ● ● ● ● ●●● ● ● ● ●●● ● ● 15 ●● ●● ●● ● ● ● ● ● ●● geom controls ●● “type” of plot 10 15 20 25 30 35 qplot(cty, hwy, data = mpg, geom = "jitter") cty
  • 28. ● ● 40 ● ● 35 ● ● ● ● ● ● ● ● 30 ● ● ● ● ● hwy ● ● ● ● ● ● ● ● ● ● ● ● 25 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 20 ● ● ● ● ● ● ● ● ● ● ● ● 15 ● ● ● ● ● 2seater compact midsize minivan pickup subcompact suv qplot(class, hwy, data = mpg) class
  • 29. How could ● ● we improve ● 40 this plot? ● ● 35 ● ● Brainstorm ● ● ● ● ● ● 30 for 1 minute. ● ● ● ● ● hwy ● ● ● ● ● ● ● ● ● ● ● ● 25 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 20 ● ● ● ● ● ● ● ● ● ● ● ● 15 ● ● ● ● ● 2seater compact midsize minivan pickup subcompact suv qplot(class, hwy, data = mpg) class
  • 30. ● ● 40 ● ● 35 ● ● ● ● ● ● ● ● 30 ● ● ● ● ● hwy ● ● ● ● ● ● ● ● ● ● ● ● 25 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 20 ● ● ● ● ● ● ● ● ● ● ● ● 15 ● ● ● ● ● pickup suv minivan 2seater midsize subcompact compact reorder(class, hwy)
  • 31. ● ● 40 ● ● 35 ● ● ● ● ● ● ● ● 30 ● ● ● ● ● hwy ● ● ● ● ● ● ● ● ● ● ● ● 25 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 20 ● ● ● ● ● ● ● ● ● ● ● ● 15 ● ● Incredibly useful ● ● technique! ● pickup suv minivan 2seater midsize subcompact compact qplot(reorder(class, hwy), hwy, data = mpg) reorder(class, hwy)
  • 32. ● ● 40 ● ● ● ● ● 35 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 30 ● ● ● ● ● ● ●● ● ●● ● ● ● ● ● ● ●● ● ● ● ●● ● ● ● ● ● ● ● ● hwy ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ●● ● ● ● ● ●● ●● ● ● ● ● ● ● ● ● ●●● ● ● ● ● ●● ● ● ● ● ● ● 25 ● ● ● ● ●● ●● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 20 ● ● ● ● ● ●● ● ● ● ●● ●● ●● ● ● ●● ● ● ● ● ● ●● ● ●●● ● ● ● ● ● ● ● ●● ● ● ● ●●● ● ● ● ● ● ● ● ● ●● ● ● ● ●● ● ● ● ● ● ● ● ● 15 ● ● ● ● ● ● ● ● ● ● ● ● ● ● pickup suv minivan 2seater midsize subcompact compact qplot(reorder(class, hwy),reorder(class, hwy) = mpg, geom = "jitter") hwy, data
  • 33. ● ● 40 ● 35 ● 30 hwy ● ● 25 ● ● ● ● 20 ● 15 ● ● pickup suv minivan 2seater midsize subcompact compact qplot(reorder(class, hwy), hwy, data hwy)mpg, geom = "boxplot") reorder(class, =
  • 34. ● ● ● ● ● 40 ● ● ● ● 35 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● 30 ● ● ● ● ●● ●● ● ● ● ● ●● ● ●●● ●● ●● ● ●● ● ● ● ● ● hwy ● ● ● ● ● ● ●● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●●● ● ●● ● ● ●● ● ●● ● ●● ● ● ● ● ● ● ● ●● ● ● 25 ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 20 ● ● ●● ● ● ● ● ● ●● ● ●● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ●● ●●●●● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 15 ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● qplot(reorder(class,minivan pickup suv hwy), 2seater data = subcompact hwy, midsize mpg, compact geom = c("jitter", "boxplot")) reorder(class, hwy)
  • 35. Your turn Read the help for reorder. Redraw the previously plots with class ordered by median hwy. How would you put the jittered points on top of the boxplots?
  • 36. Aside: coding strategy At the end of each interactive session, you want a summary of everything you did. Two options: 1. Save everything you did with savehistory() then remove the unimportant bits. 2. Build up the important bits as you go. (this is how I work)