
i
i
“K23166” — 2015/1/28 — 9:35 — page 197 — #223
i
i
i
i
i
i
12.4. DATA SCRAPING 197
the line before this processing. These date/time values are read into the timeval vector.
Even-numbered lines are read into the rank vector, after removing the strings salesrank=
and NA (again using two calls to gsub()). Finally, we make a dataframe (A.4.6) from the
two vectors and display the first few lines using the head() function (1.2.1).
> library(RCurl)
> myurl =
getURL("https://www3.amherst.edu/~nhorton/r2/datasets/cartoon.txt",
ssl.verifypeer=FALSE)
> file = readLines(textConnection(myurl))
> n = length(file)/2
> rank = numeric(n)
> timeval = as.POSIXlt(rank, origin="1960-01-01") ...