How to import built-in datasets in R
Overview
R is a representative statistical programming language that not only provides useful methods but also offers data sets that are good as examples. Without such data sets, one would have to download and load new data every time when giving lectures.
Guide
The method to load a data set is very simple. All you need to do is assign the name of the data set you want to load to the variable we will use. Let’s take a look at the Iris (flower) data, which you will see worn out as an example while studying statistics.
Each column represents the length and width of the sepal, the length and width of the petal, and the species, respectively. Although each column has a name, if it is difficult to understand the data with just this, enter ?iris to read the help.
Of course, the Iris is not the only data set available. Entering library(help=datasets) in the console window will show a list of available data sets and brief descriptions as shown below.
Broad Classification
Regression Analysis
- attitude
- LifeCycleSavings
- Loblolly
- attenu
- faithful
- iris
- quakes
- wiss
- trees
Time Series
- AirPassengers
- BJsales
- EuStockMarkets
- WorldPhones
- JohnsonJohnson
- LakeHuron
- Nile
- UKDriverDeaths
- UKgas
- USAccDeaths
- USPersonalExpenditure
- WWWusage
- airmiles
- airquality
- austres
- co2
- discoveries
- freeny
- lh
- longley
- lynx
- nhtemp
- nottem
- presidents
- sunspot.month
- sunspot.year
- sunspots
- treering
- uspop
Multivariate
- Harman23.cor
- Harman74.cor
- USJudgeRatings
Categorical
- HairEyeColor
- Titanic
- UCBAdmissions
- ability.cov
Experimental
- CO2
- ChickWeight
- DNase
- Indometh
- InsectSprays
- Orange
- OrchardSprays
- PlantGrowth
- Puromycin
- Theoph
- cars
- chickwts
- morley
- mtcars
- npk
- pressure
- warpbreaks
Small Samples
- BOD
- Formaldehyde
- VADeaths
- anscombe
- euro
- sleep
- stackloss
- women
Others
- crimtab
- esoph
- eurodist
- islands
- occupationalStatus
- precip
- randu
- rivers
- rock
- volcano