Download the data set: Auto.csv1 Make sure place it in the same directory of your R file and set your working directory
An easy way to load such data into R is to save it as a csv (comma separated value) file and then use the read.csv()
function to load it in.
> Auto=read.csv("Auto.csv",header=T,na.strings ="?")
> fix(Auto)
> dim(Auto)
[1] 397 9
> Auto[1:4,]
The dim()
function tells us that the data has 397 observations, or rows, and nine variables, or columns.
There are various ways to deal with the missing data.
In this case, only five of the rows contain missing observations, and so we choose to use the na.omit()
function to simply remove these rows.
Auto
with the header parameter set to TRUE and na.strings parameter set to “?”Auto
to Auto.dim1
na.omit()
function to remove the missing observations of Auto
and store the new dataset to Auto2
Auto2
to Auto.dim2