- Hands-On Exploratory Data Analysis with R
- Radhika Datar Harish Garg
- 348字
- 2021-06-24 14:10:43
About the dataset
The dataset that we will be focusing on throughout this chapter is the Auto.MPG dataset, which is used predominantly with the R language. This dataset gives the complete details of fuel economy data for the years 1999 and 2008 for 38 popular car models. This dataset also comes with the ggplot2 package, which we will cover in the coming chapters.
For now, we will focus on importing the dataset from the CSV file, which you can download from the following link:
https://github.com/PacktPublishing/Hands-On-Exploratory-Data-Analysis-with-R/tree/master/ch03
For more details pertaining to the dataset, you can refer to the following link:
https://archive.ics.uci.edu/ml/datasets/auto+mpg
Once the download is complete, we can import the CSV file into the dataset. With this conversion, we can include the dataset in the R workspace:
> mpg <-read.csv("highway_mpg.csv", stringsAsFactors = FALSE)
> View(mpg)
From this, we get the following output:

As shown in the preceding screenshot, the Auto.MPG dataset includes various attributes, as follows:

The dataset, which is represented in tabular format, is as follows:

The description, including data types for each attribute of the dataset, can be achieved with the following command:
> str(mpg) 'data.frame': 234 obs. of 11 variables: $ manufacturer: chr "audi" "audi" "audi" "audi" ... $ model : chr "a4" "a4" "a4" "a4" ... $ displ : num 1.8 1.8 2 2 2.8 2.8 3.1 1.8 1.8 2 ... $ year : int 1999 1999 2008 2008 1999 1999 2008 1999 1999 2008 ... $ cyl : int 4 4 4 4 6 6 6 4 4 4 ... $ trans : chr "auto(l5)" "manual(m5)" "manual(m6)" "auto(av)" ... $ drv : chr "f" "f" "f" "f" ... $ cty : int 18 21 20 21 16 18 18 18 16 20 ... $ hwy : int 29 29 31 30 26 26 27 26 25 28 ... $ fl : chr "p" "p" "p" "p" ... $ class : chr "compact" "compact" "compact" "compact" ...
The str function is declared as an alternative to the summary function. It displays the internal structure of an R object in a compact manner.
- Hands-On Intelligent Agents with OpenAI Gym
- 玩轉(zhuǎn)智能機(jī)器人程小奔
- AWS:Security Best Practices on AWS
- 程序設(shè)計(jì)語(yǔ)言與編譯
- Blockchain Quick Start Guide
- 基于32位ColdFire構(gòu)建嵌入式系統(tǒng)
- 愛(ài)犯錯(cuò)的智能體
- Troubleshooting OpenVPN
- 內(nèi)模控制及其應(yīng)用
- DevOps Bootcamp
- SQL Server數(shù)據(jù)庫(kù)應(yīng)用基礎(chǔ)(第2版)
- 傳感器與自動(dòng)檢測(cè)
- 筆記本電腦維修之電路分析基礎(chǔ)
- 機(jī)器人制作入門(mén)(第4版)
- Data Analysis with R(Second Edition)