logo

How to Load Built-in Datasets in R 📂R

How to Load Built-in Datasets in R

Overview

R is a representative statistical programming language that provides not only useful methods but also datasets that are convenient to use as examples. Without such datasets, one would have to download and load new data every time a lecture is given.

Guide

Loading a dataset is very simple. All you need to do is assign the name of the dataset you want to load to a variable that we will use. Let’s take a look at the iris (flower) data, which you will see over and over again as an example while studying statistics.

20171120\_124856.png Each column, in order, represents the sepal length, width, petal length, width, and species. Although each column has a name written on it, if it is hard to grasp the data with just that, type ?iris to read the help.

20171120\_125434.png Of course, iris is not the only dataset available. If you type library(help=datasets) in the console window, you can see a list of loadable datasets along with brief descriptions, as shown below.

20171120\_124643.png

Rough 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

Experiment

  • CO2
  • ChickWeight
  • DNase
  • Indometh
  • InsectSprays
  • Orange
  • OrchardSprays
  • PlantGrowth
  • Puromycin
  • Theoph
  • cars
  • chickwts
  • morley
  • mtcars
  • npk
  • pressure
  • warpbreaks

Small Sample

  • BOD
  • Formaldehyde
  • VADeaths
  • anscombe
  • euro
  • sleep
  • stackloss
  • women

Others

  • crimtab
  • esoph
  • eurodist
  • islands
  • occupationalStatus
  • precip
  • randu
  • rivers
  • rock
  • volcano