A Report Generated by knitr

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

    # Chapter 12 Getting Data into and out of R NOTE : Most of the code depends on actions,
    # directories and the presence of files. Code that isn't runnable is commented out.
    # Getting Data into R Entering data in the R text editor
    elements <- data.frame()
    # elements <- edit(elements) print(elements) Using the Clipboard to copy and paste Reminder
    # : This only works on Windows # x <- readClipboard() x # x <- readClipboard() x x <-
    # read.table(file = 'clipboard', sep = '\t', header=TRUE) x Reading data in CSV files
    # Using read.csv() to import data elements <- read.csv(file.path('f:', 'elements.csv'))
    # str(elements) elements <- read.csv(file.path('f:', 'elements.csv'),
    # stringsAsFactors=FALSE) str(elements) Using read.table() to import tabular data in text
    # files Reading data from Excel install.packages('XLConnect') library('XLConnect')
    # excel.file <- file.path('~/Elements.xlsx') elements <- readWorksheetFromFile(excel.file,
    # sheet=1) elements <- readWorksheetFromFile(excel.file, sheet='Sheet1') Working with other
    # data types library(foreign) read.spss(file='location/of/myfile') Getting Your Data out of
    # R writeClipboard(names(iris)) write.table(head(iris), file='clipboard', sep='\t',
    # row.names=FALSE) Working with Files and Folders Understanding the working directory
    getwd()

    ## [1] "C:/Users/Andrie/Documents/GitHub/rfordummies/rfordummies/inst/scripts/3-html"

    # setwd('F:/git/roxygen2') getwd() setwd('F:\\git\\stringr') getwd()
    file.path("f:", "git", "surveyor")

    ## [1] "f:/git/surveyor"

    # setwd(file.path('F:', 'git', 'roxygen2')) getwd()
    file.path("F:", "git", "roxygen2", "roxygen2", "README.md")

    ## [1] "F:/git/roxygen2/roxygen2/README.md"

    ## Manipulating files list.files(file.path('F:', 'git', 'roxygen2'))
    my.file <- tempfile()
    my.file

    ## [1] "C:\\Users\\Andrie\\AppData\\Local\\Temp\\RtmpKC3x2f\\file36d06b3321f2"

    write.csv(iris, file = my.file)
    list.files(tempdir())

    ##  [1] "file36d0111f22c3"
    ##  [2] "file36d0118f7c19"
    ##  [3] "file36d01260574f"
    ##  [4] "file36d012891846.html"
    ##  [5] "file36d0130e2e0f"
    ##  [6] "file36d0185a6657"
    ##  [7] "file36d018e8340f"
    ##  [8] "file36d01bc0161c"
    ##  [9] "file36d01c3278dd"
    ## [10] "file36d020c11cc"
    ## [11] "file36d022b556e6"
    ## [12] "file36d022d027ba"
    ## [13] "file36d02305811"
    ## [14] "file36d0243c6f1d"
    ## [15] "file36d0259661ad"
    ## [16] "file36d027d65af9"
    ## [17] "file36d02a424f49"
    ## [18] "file36d02a8373bc"
    ## [19] "file36d02d453c97"
    ## [20] "file36d02e1864e3"
    ## [21] "file36d02ed3bf8"
    ## [22] "file36d02f65766c"
    ## [23] "file36d02fc64ed6"
    ## [24] "file36d02fe62fe0"
    ## [25] "file36d030f942fb"
    ## [26] "file36d031296066"
    ## [27] "file36d032c118a"
    ## [28] "file36d0359b3b4f"
    ## [29] "file36d03743466"
    ## [30] "file36d038c93875"
    ## [31] "file36d03b182058"
    ## [32] "file36d03c0364a3"
    ## [33] "file36d03ce017f5"
    ## [34] "file36d03e7a2a0d"
    ## [35] "file36d03f8d531d"
    ## [36] "file36d03ffe5964"
    ## [37] "file36d0459d4b68"
    ## [38] "file36d045d469c3"
    ## [39] "file36d045d95084"
    ## [40] "file36d048087b57"
    ## [41] "file36d049653dcc"
    ## [42] "file36d04e4b45e0.html"
    ## [43] "file36d04fef4384"
    ## [44] "file36d0509b50b7"
    ## [45] "file36d0516d5739"
    ## [46] "file36d051b7cdb"
    ## [47] "file36d058333319"
    ## [48] "file36d05840101d"
    ## [49] "file36d05c682b5"
    ## [50] "file36d05d4c60c4"
    ## [51] "file36d05eee16fd"
    ## [52] "file36d0613f1290"
    ## [53] "file36d061ce7370"
    ## [54] "file36d065572ab6"
    ## [55] "file36d065a87150"
    ## [56] "file36d066d162f3"
    ## [57] "file36d067554d73"
    ## [58] "file36d06876a19"
    ## [59] "file36d06b3321f2"
    ## [60] "file36d06ead4880"
    ## [61] "file36d06f755e60"
    ## [62] "file36d070746b34"
    ## [63] "file36d072461660"
    ## [64] "file36d07aea174a"
    ## [65] "file36d07b6f7a50"
    ## [66] "file36d07ca4f68"
    ## [67] "file36d07d5150e1"
    ## [68] "file36d07e2424e"
    ## [69] "file36d07eb87f1a"
    ## [70] "file36d08eb2d"
    ## [71] "file36d09713819"
    ## [72] "file36d0b2b7f5d"
    ## [73] "file36d0c768a"
    ## [74] "file36d0c857681"
    ## [75] "file36d0d0f4fb1"
    ## [76] "file36d0d531862"
    ## [77] "libloc_194_393488e2.rds"
    ## [78] "libloc_194_69469b3c.rds"
    ## [79] "libloc_197_fc1ea7ea.rds"
    ## [80] "repos_http%3a%2f%2fcran.ma.imperial.ac.uk%2fbin%2fwindows%2fcontrib%2f3.0.rds"
    ## [81] "repos_http%3a%2f%2fcran.ma.imperial.ac.uk%2fsrc%2fcontrib.rds"
    ## [82] "repos_http%3a%2f%2fwww.bioconductor.org%2fpackages%2f2.13%2fbioc%2fbin%2fwindows%2fcontrib%2f3.0.rds"
    ## [83] "repos_http%3a%2f%2fwww.bioconductor.org%2fpackages%2f2.13%2fbioc%2fsrc%2fcontrib.rds"
    ## [84] "sorttable.js"

    file.iris <- read.csv(my.file)
    file.remove(my.file)

    ## [1] TRUE

    list.files(tempdir())

    ##  [1] "file36d0111f22c3"
    ##  [2] "file36d0118f7c19"
    ##  [3] "file36d01260574f"
    ##  [4] "file36d012891846.html"
    ##  [5] "file36d0130e2e0f"
    ##  [6] "file36d0185a6657"
    ##  [7] "file36d018e8340f"
    ##  [8] "file36d01bc0161c"
    ##  [9] "file36d01c3278dd"
    ## [10] "file36d020c11cc"
    ## [11] "file36d022b556e6"
    ## [12] "file36d022d027ba"
    ## [13] "file36d02305811"
    ## [14] "file36d0243c6f1d"
    ## [15] "file36d0259661ad"
    ## [16] "file36d027d65af9"
    ## [17] "file36d02a424f49"
    ## [18] "file36d02a8373bc"
    ## [19] "file36d02d453c97"
    ## [20] "file36d02e1864e3"
    ## [21] "file36d02ed3bf8"
    ## [22] "file36d02f65766c"
    ## [23] "file36d02fc64ed6"
    ## [24] "file36d02fe62fe0"
    ## [25] "file36d030f942fb"
    ## [26] "file36d031296066"
    ## [27] "file36d032c118a"
    ## [28] "file36d0359b3b4f"
    ## [29] "file36d03743466"
    ## [30] "file36d038c93875"
    ## [31] "file36d03b182058"
    ## [32] "file36d03c0364a3"
    ## [33] "file36d03ce017f5"
    ## [34] "file36d03e7a2a0d"
    ## [35] "file36d03f8d531d"
    ## [36] "file36d03ffe5964"
    ## [37] "file36d0459d4b68"
    ## [38] "file36d045d469c3"
    ## [39] "file36d045d95084"
    ## [40] "file36d048087b57"
    ## [41] "file36d049653dcc"
    ## [42] "file36d04e4b45e0.html"
    ## [43] "file36d04fef4384"
    ## [44] "file36d0509b50b7"
    ## [45] "file36d0516d5739"
    ## [46] "file36d051b7cdb"
    ## [47] "file36d058333319"
    ## [48] "file36d05840101d"
    ## [49] "file36d05c682b5"
    ## [50] "file36d05d4c60c4"
    ## [51] "file36d05eee16fd"
    ## [52] "file36d0613f1290"
    ## [53] "file36d061ce7370"
    ## [54] "file36d065572ab6"
    ## [55] "file36d065a87150"
    ## [56] "file36d066d162f3"
    ## [57] "file36d067554d73"
    ## [58] "file36d06876a19"
    ## [59] "file36d06ead4880"
    ## [60] "file36d06f755e60"
    ## [61] "file36d070746b34"
    ## [62] "file36d072461660"
    ## [63] "file36d07aea174a"
    ## [64] "file36d07b6f7a50"
    ## [65] "file36d07ca4f68"
    ## [66] "file36d07d5150e1"
    ## [67] "file36d07e2424e"
    ## [68] "file36d07eb87f1a"
    ## [69] "file36d08eb2d"
    ## [70] "file36d09713819"
    ## [71] "file36d0b2b7f5d"
    ## [72] "file36d0c768a"
    ## [73] "file36d0c857681"
    ## [74] "file36d0d0f4fb1"
    ## [75] "file36d0d531862"
    ## [76] "libloc_194_393488e2.rds"
    ## [77] "libloc_194_69469b3c.rds"
    ## [78] "libloc_197_fc1ea7ea.rds"
    ## [79] "repos_http%3a%2f%2fcran.ma.imperial.ac.uk%2fbin%2fwindows%2fcontrib%2f3.0.rds"
    ## [80] "repos_http%3a%2f%2fcran.ma.imperial.ac.uk%2fsrc%2fcontrib.rds"
    ## [81] "repos_http%3a%2f%2fwww.bioconductor.org%2fpackages%2f2.13%2fbioc%2fbin%2fwindows%2fcontrib%2f3.0.rds"
    ## [82] "repos_http%3a%2f%2fwww.bioconductor.org%2fpackages%2f2.13%2fbioc%2fsrc%2fcontrib.rds"
    ## [83] "sorttable.js"

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:05 BST"