Built in Datasets in R

 

Built-in Datasets in R

Introduction

R comes with many built-in datasets that are useful for learning statistics, visualization, and machine learning. These datasets are automatically installed with R or with certain packages and can be loaded directly without downloading any files.

Built-in datasets are used for:

  • Learning R programming
  • Statistical analysis
  • Data visualization
  • Machine learning experiments
  • Demonstrating algorithms

Viewing Available Datasets

To list all available datasets:

data()

This displays all datasets available from installed packages.

data(package = .packages(all.available = TRUE))

Data sets in package ‘boot’:

acme                   Monthly Excess Returns
aids                   Delay in AIDS Reporting in England and Wales
aircondit              Failures of Air-conditioning Equipment
aircondit7             Failures of Air-conditioning Equipment
amis                   Car Speeding and Warning Signs
aml                    Remission Times for Acute Myelogenous
                       Leukaemia
beaver                 Beaver Body Temperature Data
bigcity                Population of U.S. Cities
brambles               Spatial Location of Bramble Canes
breslow                Smoking Deaths Among Doctors
calcium                Calcium Uptake Data
cane                   Sugar-cane Disease Data
capability             Simulated Manufacturing Process Data
catsM                  Weight Data for Domestic Cats
cav                    Position of Muscle Caveolae
cd4                    CD4 Counts for HIV-Positive Patients
cd4.nested             Nested Bootstrap of cd4 data
channing               Channing House Data
city                   Population of U.S. Cities
claridge               Genetic Links to Left-handedness
cloth                  Number of Flaws in Cloth
co.transfer            Carbon Monoxide Transfer
coal                   Dates of Coal Mining Disasters
darwin                 Darwin's Plant Height Differences
dogs                   Cardiac Data for Domestic Dogs
downs.bc               Incidence of Down's Syndrome in British
                       Columbia
ducks                  Behavioral and Plumage Characteristics of
                       Hybrid Ducks
fir                    Counts of Balsam-fir Seedlings
frets                  Head Dimensions in Brothers
grav                   Acceleration Due to Gravity
gravity                Acceleration Due to Gravity
hirose                 Failure Time of PET Film
islay                  Jura Quartzite Azimuths on Islay
manaus                 Average Heights of the Rio Negro river at
                       Manaus
melanoma               Survival from Malignant Melanoma
motor                  Data from a Simulated Motorcycle Accident
neuro                  Neurophysiological Point Process Data
nitrofen               Toxicity of Nitrofen in Aquatic Systems
nodal                  Nodal Involvement in Prostate Cancer
nuclear                Nuclear Power Station Construction Data
paulsen                Neurotransmission in Guinea Pig Brains
poisons                Animal Survival Times
polar                  Pole Positions of New Caledonian Laterites
remission              Cancer Remission and Cell Activity
salinity               Water Salinity and River Discharge
survival               Survival of Rats after Radiation Doses
tau                    Tau Particle Decay Modes
tuna                   Tuna Sighting Data
urine                  Urine Analysis Data
wool                   Australian Relative Wool Prices

Data sets in package ‘cluster’:

agriculture            European Union Agricultural Workforces
animals                Attributes of Animals
chorSub                Subset of C-horizon of Kola Data
flower                 Flower Characteristics
plantTraits            Plant Species Traits Data
pluton                 Isotopic Composition Plutonium Batches
ruspini                Ruspini Data
votes.repub            Votes for Republican Candidate in
                       Presidential Elections
xclara                 Bivariate Data Set with 3 Clusters

Data sets in package ‘datasets’:

AirPassengers          Monthly Airline Passenger Numbers 1949-1960
BJsales                Sales Data with Leading Indicator
BJsales.lead (BJsales)
                       Sales Data with Leading Indicator
BOD                    Biochemical Oxygen Demand
CO2                    Carbon Dioxide Uptake in Grass Plants
ChickWeight            Weight Versus Age of Chicks on Different
                       Diets
DNase                  Elisa assay of DNase
EuStockMarkets         Daily Closing Prices of Major European Stock
                       Indices, 1991-1998
Formaldehyde           Determination of Formaldehyde
HairEyeColor           Hair and Eye Color of Statistics Students
Harman23.cor           Harman Example 2.3
Harman74.cor           Harman Example 7.4
Indometh               Pharmacokinetics of Indomethacin
InsectSprays           Effectiveness of Insect Sprays
JohnsonJohnson         Quarterly Earnings per Johnson & Johnson
                       Share
LakeHuron              Level of Lake Huron 1875-1972
LifeCycleSavings       Intercountry Life-Cycle Savings Data
Loblolly               Growth of Loblolly Pine Trees
Nile                   Flow of the River Nile
Orange                 Growth of Orange Trees
OrchardSprays          Potency of Orchard Sprays
PlantGrowth            Results from an Experiment on Plant Growth
Puromycin              Reaction Velocity of an Enzymatic Reaction
Seatbelts              Road Casualties in Great Britain 1969-84
Theoph                 Pharmacokinetics of Theophylline
Titanic                Survival of passengers on the Titanic
ToothGrowth            The Effect of Vitamin C on Tooth Growth in
                       Guinea Pigs
UCBAdmissions          Student Admissions at UC Berkeley
UKDriverDeaths         Road Casualties in Great Britain 1969-84
UKgas                  UK Quarterly Gas Consumption
USAccDeaths            Accidental Deaths in the US 1973-1978
USArrests              Violent Crime Rates by US State
USJudgeRatings         Lawyers' Ratings of State Judges in the US
                       Superior Court
USPersonalExpenditure
                       Personal Expenditure Data
UScitiesD              Distances Between European Cities and Between
                       US Cities
VADeaths               Death Rates in Virginia (1940)
WWWusage               Internet Usage per Minute
WorldPhones            The World's Telephones
ability.cov            Ability and Intelligence Tests
airmiles               Passenger Miles on Commercial US Airlines,
                       1937-1960
airquality             New York Air Quality Measurements
anscombe               Anscombe's Quartet of 'Identical' Simple
                       Linear Regressions
attenu                 The Joyner-Boore Attenuation Data
attitude               The Chatterjee-Price Attitude Data
austres                Quarterly Time Series of the Number of
                       Australian Residents
beaver1 (beavers)      Body Temperature Series of Two Beavers
beaver2 (beavers)      Body Temperature Series of Two Beavers
cars                   Speed and Stopping Distances of Cars
chickwts               Chicken Weights by Feed Type
co2                    Mauna Loa Atmospheric CO2 Concentration
crimtab                Student's 3000 Criminals Data
discoveries            Yearly Numbers of Important Discoveries
esoph                  Smoking, Alcohol and (O)esophageal Cancer
euro                   Conversion Rates of Euro Currencies
euro.cross (euro)      Conversion Rates of Euro Currencies
eurodist               Distances Between European Cities and Between
                       US Cities
faithful               Old Faithful Geyser Data
fdeaths (UKLungDeaths)
                       Monthly Deaths from Lung Diseases in the UK
freeny                 Freeny's Revenue Data
freeny.x (freeny)      Freeny's Revenue Data
freeny.y (freeny)      Freeny's Revenue Data
gait                   Hip and Knee Angle while Walking
infert                 Infertility after Spontaneous and Induced
                       Abortion
iris                   Edgar Anderson's Iris Data
iris3                  Edgar Anderson's Iris Data
islands                Areas of the World's Major Landmasses
ldeaths (UKLungDeaths)
                       Monthly Deaths from Lung Diseases in the UK
lh                     Luteinizing Hormone in Blood Samples
longley                Longley's Economic Regression Data
lynx                   Annual Canadian Lynx trappings 1821-1934
mdeaths (UKLungDeaths)
                       Monthly Deaths from Lung Diseases in the UK
morley                 Michelson Speed of Light Data
mtcars                 Motor Trend Car Road Tests
nhtemp                 Average Yearly Temperatures in New Haven
nottem                 Average Monthly Temperatures at Nottingham,
                       1920-1939
npk                    Classical N, P, K Factorial Experiment
occupationalStatus     Occupational Status of Fathers and their Sons
penguins               Measurements of Penguins near Palmer Station,
                       Antarctica
penguins_raw (penguins)
                       Measurements of Penguins near Palmer Station,
                       Antarctica
precip                 Annual Precipitation in Selected US Cities
presidents             Quarterly Approval Ratings of US Presidents
pressure               Vapor Pressure of Mercury as a Function of
                       Temperature
quakes                 Locations of Earthquakes off Fiji
randu                  Random Numbers from Congruential Generator
                       RANDU
rivers                 Lengths of Major North American Rivers
rock                   Measurements on Petroleum Rock Samples
sleep                  Student's Sleep Data
stack.loss (stackloss)
                       Brownlee's Stack Loss Plant Data
stack.x (stackloss)    Brownlee's Stack Loss Plant Data
stackloss              Brownlee's Stack Loss Plant Data
state.abb (state)      US State Facts and Figures
state.area (state)     US State Facts and Figures
state.center (state)   US State Facts and Figures
state.division (state)
                       US State Facts and Figures
state.name (state)     US State Facts and Figures
state.region (state)   US State Facts and Figures
state.x77 (state)      US State Facts and Figures
sunspot.m2014 (sunspot.month)
                       Monthly Sunspot Data, from 1749 to "Present"
sunspot.month          Monthly Sunspot Data, from 1749 to "Present"
sunspot.year           Yearly Sunspot Data, 1700-1988
sunspots               Monthly Sunspot Numbers, 1749-1983
swiss                  Swiss Fertility and Socioeconomic Indicators
                       (1888) Data
treering               Yearly Tree-Ring Data, -6000-1979
trees                  Diameter, Height and Volume for Black Cherry
                       Trees
uspop                  Populations Recorded by the US Census
volcano                Topographic Information on Auckland's Maunga
                       Whau Volcano
warpbreaks             The Number of Breaks in Yarn during Weaving
women                  Average Heights and Weights for American
                       Women

Data sets in package ‘dplyr’:

band_instruments       Band membership
band_instruments2      Band membership
band_members           Band membership
starwars               Starwars characters
storms                 Storm tracks data

Data sets in package ‘ggplot2’:

diamonds               Prices of over 50,000 round cut diamonds
economics              US economic time series
economics_long         US economic time series
faithfuld              2d density estimate of Old Faithful data
luv_colours            'colors()' in Luv space
midwest                Midwest demographics
mpg                    Fuel economy data from 1999 to 2008 for 38
                       popular models of cars
msleep                 An updated and expanded version of the
                       mammals sleep dataset
presidential           Terms of 12 presidents from Eisenhower to
                       Trump
seals                  Vector field of seal movements
txhousing              Housing sales in TX

Data sets in package ‘lattice’:

USMortality            Mortality Rates in US by Cause and Gender
USRegionalMortality    Mortality Rates in US by Cause and Gender
barley                 Yield data from a Minnesota barley trial
environmental          Atmospheric environmental conditions in New
                       York City
ethanol                Engine exhaust fumes from burning ethanol
melanoma               Melanoma skin cancer incidence
singer                 Heights of New York Choral Society singers

Data sets in package ‘MASS’:

Aids2                  Australian AIDS Survival Data
Animals                Brain and Body Weights for 28 Species
Boston                 Housing Values in Suburbs of Boston
Cars93                 Data from 93 Cars on Sale in the USA in 1993
Cushings               Diagnostic Tests on Patients with Cushing's
                       Syndrome
DDT                    DDT in Kale
GAGurine               Level of GAG in Urine of Children
Insurance              Numbers of Car Insurance claims
Melanoma               Survival from Malignant Melanoma
OME                    Tests of Auditory Perception in Children with
                       OME
Pima.te                Diabetes in Pima Indian Women
Pima.tr                Diabetes in Pima Indian Women
Pima.tr2               Diabetes in Pima Indian Women
Rabbit                 Blood Pressure in Rabbits
Rubber                 Accelerated Testing of Tyre Rubber
SP500                  Returns of the Standard and Poors 500
Sitka                  Growth Curves for Sitka Spruce Trees in 1988
Sitka89                Growth Curves for Sitka Spruce Trees in 1989
Skye                   AFM Compositions of Aphyric Skye Lavas
Traffic                Effect of Swedish Speed Limits on Accidents
UScereal               Nutritional and Marketing Information on US
                       Cereals
UScrime                The Effect of Punishment Regimes on Crime
                       Rates
VA                     Veteran's Administration Lung Cancer Trial
abbey                  Determinations of Nickel Content
accdeaths              Accidental Deaths in the US 1973-1978
anorexia               Anorexia Data on Weight Change
bacteria               Presence of Bacteria after Drug Treatments
beav1                  Body Temperature Series of Beaver 1
beav2                  Body Temperature Series of Beaver 2
biopsy                 Biopsy Data on Breast Cancer Patients
birthwt                Risk Factors Associated with Low Infant Birth
                       Weight
cabbages               Data from a cabbage field trial
caith                  Colours of Eyes and Hair of People in
                       Caithness
cats                   Anatomical Data from Domestic Cats
cement                 Heat Evolved by Setting Cements
chem                   Copper in Wholemeal Flour
coop                   Co-operative Trial in Analytical Chemistry
cpus                   Performance of Computer CPUs
crabs                  Morphological Measurements on Leptograpsus
                       Crabs
deaths                 Monthly Deaths from Lung Diseases in the UK
drivers                Deaths of Car Drivers in Great Britain
                       1969-84
eagles                 Foraging Ecology of Bald Eagles
epil                   Seizure Counts for Epileptics
farms                  Ecological Factors in Farm Management
fgl                    Measurements of Forensic Glass Fragments
forbes                 Forbes' Data on Boiling Points in the Alps
galaxies               Velocities for 82 Galaxies
gehan                  Remission Times of Leukaemia Patients
genotype               Rat Genotype Data
geyser                 Old Faithful Geyser Data
gilgais                Line Transect of Soil in Gilgai Territory
hills                  Record Times in Scottish Hill Races
housing                Frequency Table from a Copenhagen Housing
                       Conditions Survey
immer                  Yields from a Barley Field Trial
leuk                   Survival Times and White Blood Counts for
                       Leukaemia Patients
mammals                Brain and Body Weights for 62 Species of Land
                       Mammals
mcycle                 Data from a Simulated Motorcycle Accident
menarche               Age of Menarche in Warsaw
michelson              Michelson's Speed of Light Data
minn38                 Minnesota High School Graduates of 1938
motors                 Accelerated Life Testing of Motorettes
muscle                 Effect of Calcium Chloride on Muscle
                       Contraction in Rat Hearts
newcomb                Newcomb's Measurements of the Passage Time of
                       Light
nlschools              Eighth-Grade Pupils in the Netherlands
npk                    Classical N, P, K Factorial Experiment
npr1                   US Naval Petroleum Reserve No. 1 data
oats                   Data from an Oats Field Trial
painters               The Painter's Data of de Piles
petrol                 N. L. Prater's Petrol Refinery Data
phones                 Belgium Phone Calls 1950-1973
quine                  Absenteeism from School in Rural New South
                       Wales
road                   Road Accident Deaths in US States
rotifer                Numbers of Rotifers by Fluid Density
ships                  Ships Damage Data
shoes                  Shoe wear data of Box, Hunter and Hunter
shrimp                 Percentage of Shrimp in Shrimp Cocktail
shuttle                Space Shuttle Autolander Problem
snails                 Snail Mortality Data
steam                  The Saturated Steam Pressure Data
stormer                The Stormer Viscometer Data
survey                 Student Survey Data
synth.te               Synthetic Classification Problem
synth.tr               Synthetic Classification Problem
topo                   Spatial Topographic Data
waders                 Counts of Waders at 15 Sites in South Africa
whiteside              House Insulation: Whiteside's Data
wtloss                 Weight Loss Data from an Obese Patient

Data sets in package ‘Matrix’:

CAex                   Albers' example Matrix with "Difficult" Eigen
                       Factorization
KNex                   Koenker-Ng Example Sparse Model Matrix and
                       Response Vector
USCounties             Contiguity Matrix of U.S. Counties
wrld_1deg              Contiguity Matrix of World One-Degree Grid
                       Cells

Data sets in package ‘mgcv’:

columb                 Reduced version of Columbus OH crime data
columb.polys           Reduced version of Columbus OH crime data

Data sets in package ‘nlme’:

Alfalfa                Split-Plot Experiment on Varieties of Alfalfa
Assay                  Bioassay on Cell Culture Plate
BodyWeight             Rat weight over time for different diets
Cefamandole            Pharmacokinetics of Cefamandole
Dialyzer               High-Flux Hemodialyzer
Earthquake             Earthquake Intensity
Fatigue                Cracks caused by metal fatigue
Gasoline               Refinery yield of gasoline
Glucose                Glucose levels over time
Glucose2               Glucose Levels Following Alcohol Ingestion
Gun                    Methods for firing naval guns
IGF                    Radioimmunoassay of IGF-I Protein
Machines               Productivity Scores for Machines and Workers
MathAchSchool          School demographic data for MathAchieve
MathAchieve            Mathematics achievement scores
Meat                   Tenderness of meat
Milk                   Protein content of cows' milk
Muscle                 Contraction of heart muscle sections
Nitrendipene           Assay of nitrendipene
Oats                   Split-plot Experiment on Varieties of Oats
Orthodont              Growth curve data on an orthdontic
                       measurement
Ovary                  Counts of Ovarian Follicles
Oxboys                 Heights of Boys in Oxford
Oxide                  Variability in Semiconductor Manufacturing
PBG                    Effect of Phenylbiguanide on Blood Pressure
Phenobarb              Phenobarbitol Kinetics
Pixel                  X-ray pixel intensities over time
Quinidine              Quinidine Kinetics
Rail                   Evaluation of Stress in Railway Rails
RatPupWeight           The weight of rat pups
Relaxin                Assay for Relaxin
Remifentanil           Pharmacokinetics of Remifentanil
Soybean                Growth of soybean plants
Spruce                 Growth of Spruce Trees
Tetracycline1          Pharmacokinetics of tetracycline
Tetracycline2          Pharmacokinetics of tetracycline
Wafer                  Modeling of Analog MOS Circuits
Wheat                  Yields by growing conditions
Wheat2                 Wheat Yield Trials
bdf                    Language scores
ergoStool              Ergometrics experiment with stool types

Data sets in package ‘plotly’:

hobbs                  Hobbs data
mic                    Mic data
res_mn                 Minnesotan Indian Reservation Lands
wind                   Wind data

Data sets in package ‘plotrix’:

death_reg              Death registrations from 1996 to 2010
l2010                  World lightning strike data from 2010
soils                  Soil texture data from 125 soils

Data sets in package ‘rpart’:

car.test.frame         Automobile Data from 'Consumer Reports' 1990
car90                  Automobile Data from 'Consumer Reports' 1990
cu.summary             Automobile Data from 'Consumer Reports' 1990
kyphosis               Data on Children who have had Corrective
                       Spinal Surgery
solder                 Soldering of Components on Printed-Circuit
                       Boards
solder.balance (solder)
                       Soldering of Components on Printed-Circuit
                       Boards
stagec                 Stage C Prostate Cancer

Data sets in package ‘stringr’:

fruit                  Sample character vectors for practicing
                       string manipulations
sentences              Sample character vectors for practicing
                       string manipulations
words                  Sample character vectors for practicing
                       string manipulations

Data sets in package ‘survival’:

aml (cancer)           Acute Myelogenous Leukemia survival data
bladder (cancer)       Bladder Cancer Recurrences
bladder1 (cancer)      Bladder Cancer Recurrences
bladder2 (cancer)      Bladder Cancer Recurrences
braking (reliability)
                       Reliability data sets
cancer                 NCCTG Lung Cancer Data
capacitor (reliability)
                       Reliability data sets
cgd                    Chronic Granulotamous Disease data
cgd0 (cgd)             Chronic Granulotomous Disease data
colon (cancer)         Chemotherapy for Stage B/C colon cancer
cracks (reliability)   Reliability data sets
diabetic               Ddiabetic retinopathy
flchain                Assay of serum free light chain for 7874
                       subjects.
gbsg (cancer)          Breast cancer data sets used in Royston and
                       Altman (2013)
genfan (reliability)   Reliability data sets
heart                  Stanford Heart Transplant data
hoel (cancer)          Mouse cancer data
ifluid (reliability)   Reliability data sets
imotor (reliability)   Reliability data sets
jasa (heart)           Stanford Heart Transplant data
jasa1 (heart)          Stanford Heart Transplant data
kidney (cancer)        Kidney catheter data
leukemia (cancer)      Acute Myelogenous Leukemia survival data
logan                  Data from the 1972-78 GSS data used by Logan
lung (cancer)          NCCTG Lung Cancer Data
mgus (cancer)          Monoclonal gammopathy data
mgus1 (cancer)         Monoclonal gammopathy data
mgus2 (cancer)         Monoclonal gammopathy data
myeloid (cancer)       Acute myeloid leukemia
myeloma (cancer)       Survival times of patients with multiple
                       myeloma
nafld1 (nafld)         Non-alcoholic fatty liver disease
nafld2 (nafld)         Non-alcoholic fatty liver disease
nafld3 (nafld)         Non-alcoholic fatty liver disease
nwtco                  Data from the National Wilm's Tumor Study
ovarian (cancer)       Ovarian Cancer Survival Data
pbc                    Mayo Clinic Primary Biliary Cholangitis Data
pbcseq (pbc)           Mayo Clinic Primary Biliary Cirrhosis,
                       sequential data
rats (cancer)          Rat treatment data from Mantel et al
rats2 (cancer)         Rat data from Gail et al.
retinopathy            Diabetic Retinopathy
rhDNase                rhDNASE data set
rotterdam (cancer)     Breast cancer data set used in Royston and
                       Altman (2013)
solder                 Data from a soldering experiment
stanford2 (heart)      More Stanford Heart Transplant data
survexp.mn (survexp)   Census Data Sets for the Expected Survival
                       and Person Years Functions
survexp.us (survexp)   Census Data Sets for the Expected Survival
                       and Person Years Functions
survexp.usr (survexp)
                       Census Data Sets for the Expected Survival
                       and Person Years Functions
tobin                  Tobin's Tobit data
transplant             Liver transplant waiting list
turbine (reliability)
                       Reliability data sets
udca                   Data from a trial of usrodeoxycholic acid
udca1 (udca)           Data from a trial of usrodeoxycholic acid
udca2 (udca)           Data from a trial of usrodeoxycholic acid
uspop2 (survexp)       Projected US Population
valveSeat (reliability)
                       Reliability data sets
veteran (cancer)       Veterans' Administration Lung Cancer study

Data sets in package ‘tidyr’:

billboard              Song rankings for Billboard top 100 in the
                       year 2000
cms_patient_care       Data from the Centers for Medicare & Medicaid
                       Services
cms_patient_experience
                       Data from the Centers for Medicare & Medicaid
                       Services
construction           Completed construction in the US in 2018
fish_encounters        Fish encounters
household              Household data
population             World Health Organization TB data
relig_income           Pew religion and income survey
smiths                 Some data about the Smith family
table1                 Example tabular representations
table2                 Example tabular representations
table3                 Example tabular representations
table4a                Example tabular representations
table4b                Example tabular representations
table5                 Example tabular representations
us_rent_income         US rent and income data
who                    World Health Organization TB data
who2                   World Health Organization TB data
world_bank_pop         Population data from the World Bank


Viewing a Particular Dataset

For example:

data(iris)

To display the dataset:

head(iris)

or

View(iris)

To get information:

help(iris)

or

?iris

Structure of a Dataset

str(iris)

Summary:

summary(iris)

Dimensions:

dim(iris)

Common Built-in Datasets


1. iris

One of the most famous datasets used in machine learning.

data(iris)
head(iris)

Variables

  • Sepal.Length
  • Sepal.Width
  • Petal.Length
  • Petal.Width
  • Species

Applications

  • Classification
  • Clustering
  • Visualization

Size

150 × 5


2. mtcars

Motor Trend Car Road Tests dataset.

data(mtcars)
head(mtcars)

Variables

  • mpg
  • cyl
  • hp
  • wt
  • gear
  • carb

Applications

  • Regression
  • Correlation analysis

Size

32 × 11


3. airquality

Air quality measurements in New York.

data(airquality)
head(airquality)

Variables

  • Ozone
  • Solar.R
  • Wind
  • Temp
  • Month
  • Day

Applications

  • Environmental analysis
  • Regression

Size

153 × 6


4. ToothGrowth

Effect of vitamin C on tooth growth.

data(ToothGrowth)
head(ToothGrowth)

Variables

  • len
  • supp
  • dose

Applications

  • Statistical tests
  • Box plots

Size

60 × 3


5. ChickWeight

Growth of chickens over time.

data(ChickWeight)
head(ChickWeight)

Variables

  • weight
  • Time
  • Chick
  • Diet

Applications

  • Growth analysis
  • Time series

6. PlantGrowth

Weights of plants under different treatments.

data(PlantGrowth)
head(PlantGrowth)

Variables

  • weight
  • group

Applications

  • ANOVA
  • Box plots

7. faithful

Old Faithful geyser eruption data.

data(faithful)
head(faithful)

Variables

  • eruptions
  • waiting

Applications

  • Clustering
  • Scatter plots

8. pressure

Pressure and temperature data.

data(pressure)
head(pressure)

Variables

  • temperature
  • pressure

Applications

  • Line graphs
  • Regression

9. women

Height and weight data.

data(women)
head(women)

Variables

  • height
  • weight

Applications

  • Correlation
  • Regression

10. USArrests

Crime statistics in US states.

data(USArrests)
head(USArrests)

Variables

  • Murder
  • Assault
  • UrbanPop
  • Rape

Applications

  • Clustering
  • PCA

Size

50 × 4


11. Titanic

Survival data from Titanic disaster.

data(Titanic)
Titanic

Convert to data frame:

df <- as.data.frame(Titanic)
head(df)

Applications

  • Classification
  • Decision trees

12. trees

Tree measurements.

data(trees)
head(trees)

Variables

  • Girth
  • Height
  • Volume

Applications

  • Regression

13. CO2

Carbon dioxide uptake in plants.

data(CO2)
head(CO2)

Applications

  • ANOVA
  • Growth analysis

14. state.x77

Statistics for US states.

head(state.x77)

Variables

  • Population
  • Income
  • Illiteracy
  • Life Expectancy

Applications

  • Multivariate analysis

15. cars

Speed and stopping distances.

data(cars)
head(cars)

Variables

  • speed
  • dist

Applications

  • Regression
  • Scatter plots

16. volcano

Topographic information.

data(volcano)

3D Surface:

library(plotly)

plot_ly(z=volcano,
type='surface')

Applications

  • Heatmaps
  • Surface plots

17. Orange

Growth of orange trees.

data(Orange)
head(Orange)

Applications

  • Time series
  • Regression

18. BOD

Biochemical Oxygen Demand.

data(BOD)
head(BOD)

Applications

  • Environmental studies

19. EuStockMarkets

European stock market indices.

data(EuStockMarkets)

Convert to data frame:

df <- as.data.frame(EuStockMarkets)
head(df)

Applications

  • Time series
  • Forecasting

20. rivers

Lengths of rivers.

data(rivers)
head(rivers)

Applications

  • Histograms
  • Descriptive statistics

Datasets in the datasets Package

To view only datasets package datasets:

data(package="datasets")

Loading a Dataset

data(iris)

Display first six rows:

head(iris)

Display last six rows:

tail(iris)

Structure

str(iris)

Summary Statistics

summary(iris)

Dimensions

dim(iris)

Column Names

names(iris)

Plotting Dataset

Scatter plot:

plot(iris$Sepal.Length,
iris$Petal.Length)

Box plot:

boxplot(Sepal.Length~Species,
data=iris)

Histogram:

hist(iris$Sepal.Length)

Datasets from Other Packages

MASS package

library(MASS)

data(Boston)

Housing dataset.


ISLR package

library(ISLR)

data(Auto)

Automobile dataset.


mlbench package

library(mlbench)

data(PimaIndiansDiabetes)

Diabetes classification dataset.


ggplot2 package

library(ggplot2)

data(diamonds)

Diamond prices dataset.


Summary Table

DatasetRowsApplications
iris150Classification
mtcars32Regression
airquality153Environmental analysis
ToothGrowth60ANOVA
PlantGrowth30Statistical tests
faithful272Clustering
USArrests50PCA
trees31Regression
cars50Scatter plots
Titanic32Classification
CO284Growth studies
ChickWeight578Time series
pressure19Line plots
women15Correlation
volcano87×61Surface plots

Conclusion

R contains numerous built-in datasets that provide convenient examples for learning statistics, graphics, machine learning, and data analysis. Functions such as

data()
head()
tail()
str()
summary()
View()

allow users to explore these datasets easily. Datasets like iris, mtcars, airquality, and Titanic are among the most widely used datasets for teaching and experimentation in R.

Comments

Popular posts from this blog

Statistical Methods Lab ( R Language) PCCBL308 Semester 3 KTU BTech CB and CU 2024 Scheme - Dr Binu V P

Programs in R - using control statements - Assignment 2

Basic R Programs to Try - Assignment 1