############# ## Code of Slides: Data Importing in R ############# ####### Section: R Internal Data Set Format ## data() ## data(package="DMwR") # data sets from a specific package data(package = .packages(all.available = TRUE)) # all packages ## data(iris) head(iris) ## dat <- data.frame(x=rnorm(10),y=rnorm(10)) save(dat,file="exp.RData") ## rm(dat) # remove dat from the computer memory dat # confirming that it was deleted load("exp.RData") # load it back from the file head(dat) # here it is again! ####### Section: Data Sets in Text Files ## library(readr) dat <- read_csv("x.csv",col_types = "cci") dat ## dat <- read_csv2("y.csv", col_types = "ccd") dat ## dat <- read_table2("z.txt",na="???",col_types = "ccic") dat ####### Section: Importing from Spreadsheets ## dat <- read.table("clipboard",header=TRUE) ## dat ## library(readxl) fc <- "c:\\Documents and Settings\\xpto\\My Documents\\calc.xls" dat <- read_excel(fc,sheet="MayValues") dat2 <- read_excel(fc,sheet=2) dat <- read_excel(fc,sheet="MayValues", range="C2:F24")