Once you have downloaded and installed everything in the previous recipe, Preparing R for your first project, you can import the dataset into R to start doing some preliminary analysis and get a sense of what the data looks like.
Much of the analysis in this chapter is cumulative, and the efforts of the previous recipes will be used for subsequent recipes. Thus, if you completed the previous recipe, you should have everything you need to continue.
The following steps will walk you through the initial import of the data into the R environment:
- First, set the working directory to the location where we saved the
vehicles.csv.zip
file:
setwd("path")
Substitute the path for the actual directory.
- We can load the data directly from compressed (ZIP) files, as long as you know the filename of the file inside the ZIP archive that you want to load:
vehicles <- read.csv(unz("vehicles.csv.zip", "vehicles.csv"), stringsAsFactors...