A Report Generated by knitr

This report is automatically generated with the R package knitr (version `1.5`) .

    # Chapter 16 - Using Base Graphics Creating Different Types of Plots Getting an overview of
    # plot
    large.islands <- head(sort(islands, decreasing = TRUE), 10)
    plot(large.islands, main = "Land area of continents and islands", ylab = "Land area in square miles")
    text(large.islands, labels = names(large.islands), adj = c(0.5, 1))

    ## Adding points and lines to a plot
    plot(faithful)
    ## Adding points
    short.eruptions <- with(faithful, faithful[eruptions < 3, ])
    plot(faithful)
    points(short.eruptions, col = "red", pch = 19)

    ## Changing the shape of points Changing the color
    head(colors(), 10)

    ##  [1] "white"         "aliceblue"     "antiquewhite"  "antiquewhite1" "antiquewhite2"
    ##  [6] "antiquewhite3" "antiquewhite4" "aquamarine"    "aquamarine1"   "aquamarine2"

    ## Adding lines to a plot
    fit <- lm(waiting ~ eruptions, data = faithful)
    plot(faithful)
    lines(faithful$eruptions, fitted(fit), col = "blue")
    abline(v = 3, col = "purple")
    abline(h = mean(faithful$waiting))
    abline(a = coef(fit)[1], b = coef(fit)[2])
    abline(fit, col = "red")

    # Different plot types
    plot(LakeHuron, type = "l", main = "type=\"l\"")

    plot(LakeHuron, type = "p", main = "type=p\"")

    plot(LakeHuron, type = "b", main = "type=\"b\"")

    ## x <- seq(0.5, 1.5, 0.25)
    y <- rep(1, length(x))

    ## Error: object 'x' not found

    plot(x, y, type = "n")

    ## Error: object 'x' not found

    points(x, y)

    ## Error: object 'x' not found

    with(mtcars, plot(mpg, disp))

    with(mtcars, boxplot(disp, mpg))

    with(mtcars, hist(mpg))

    # Controlling Plot Options and Arguments Adding titles and axis labels
    plot(faithful, main = "Eruptions of Old Faithful", xlab = "Eruption time (min)", ylab = "Waiting time to next eruption (min)")

    ## Changing plot options The axes label style
    plot(faithful, las = 1)

    ### The box type
    plot(faithful, bty = "n")

    ### More than one option
    plot(faithful, las = 1, bty = "l", col = "red", pch = 19)

    ### Font size of text and axes x <- seq(0.5, 1.5, 0.25)
    y <- rep(1, length(x))

    ## Error: object 'x' not found

    plot(x, y, main = "Effect of cex on text size")

    ## Error: object 'x' not found

    text(x, y + 0.1, labels = x, cex = x)

    ## Error: object 'x' not found

    plot(x, y, main = "Effect of cex.main, cex.lab and cex.axis", cex.main = 1.25, cex.lab = 1.5,
        cex.axis = 0.75)

    ## Error: object 'x' not found

    ## Putting multiple plots on a single page
    old.par <- par(mfrow = c(1, 2))
    plot(faithful, main = "Faithful eruptions")
    plot(large.islands, main = "Islands", ylab = "Area")

    par(old.par)
    # Saving Graphics to Image Files
    setwd("~/")
    getwd()

    ## [1] "C:/Users/Andrie/Documents"

    png(filename = "faithful.png")
    plot(faithful)
    dev.off()

    ## pdf
    ##   2

The R session information (including the OS info, R version and all packages used):

    sessionInfo()

    ## R version 3.0.2 (2013-09-25)
    ## Platform: x86_64-w64-mingw32/x64 (64-bit)
    ##
    ## locale:
    ## [1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252
    ## [3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
    ## [5] LC_TIME=English_United Kingdom.1252
    ##
    ## attached base packages:
    ## [1] stats     graphics  grDevices utils     datasets  methods   base
    ##
    ## other attached packages:
    ##  [1] BiocInstaller_1.12.1 ggplot2_0.9.3.1      reshape2_1.2.2       sos_1.3-8
    ##  [5] brew_1.0-6           stringr_0.6.2        knitr_1.5            plyr_1.8
    ##  [9] Revobase_7.1.0       RevoMods_7.1.0       RevoScaleR_7.1.0     lattice_0.20-27
    ## [13] rpart_4.1-2
    ##
    ## loaded via a namespace (and not attached):
    ##  [1] codetools_0.2-8    colorspace_1.2-4   dichromat_2.0-0    digest_0.6.4
    ##  [5] evaluate_0.5.1     foreach_1.4.1      formatR_0.10       fortunes_1.5-2
    ##  [9] grid_3.0.2         gtable_0.1.2       highr_0.3          iterators_1.0.6
    ## [13] labeling_0.2       MASS_7.3-29        munsell_0.4.2      proto_0.3-10
    ## [17] RColorBrewer_1.0-5 scales_0.2.3       tools_3.0.2

    Sys.time()

    ## [1] "2014-05-13 15:06:19 BST"