R自带数据集介绍

在用R语言做数据分析的时候,我们经常需要一些数据做实验,尤其当学会一个新的方法或者算法的时候,就想赶快编程实现一下。那么,问题来了,用什么数据好呢,什么样的数据适合做这种实验呢?

好在R语言提供了很多的基本数据集,这些基本数据集是可以直接加载、可以完成几乎所有的数据分析任务模拟数据的。这都是些哪些种类的数据呢?

之前我们安装了 ggplot2 会使用其默认数据集,其实R语言自带也是有数据集的。

data(package = 'ggplot2') 

  

R自带基本数据集都在R包datasets里面,可以执行命令:

data(package = 'datasets')

  

就会datasets包带的出现所有基本基本数据集:

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
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
precip                 Annual Precipitation in 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.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 Treering 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

  

具体翻译一下各个数据集基本情况

向量
euro    #欧元汇率,长度为11,每个元素都有命名
landmasses    #48个陆地的面积,每个都有命名
precip    #长度为70的命名向量
rivers    #北美141条河流长度
state.abb    #美国50个州的双字母缩写
state.area    #美国50个州的面积
state.name    #美国50个州的全称


因子
state.division    #美国50个州的分类,9个类别
state.region    #美国50个州的地理分类


矩阵、数组
euro.cross    #11种货币的汇率矩阵
freeny.x    #每个季度影响收入四个因素的记录
state.x77    #美国50个州的八个指标
USPersonalExpenditure    #5个年份在5个消费方向的数据
VADeaths    #1940年弗吉尼亚州死亡率(每千人)
volcano    #某火山区的地理信息(10米×10米的网格)
WorldPhones    #8个区域在7个年份的电话总数
iris3    #3种鸢尾花形态数据
Titanic    #泰坦尼克乘员统计
UCBAdmissions    #伯克利分校1973年院系、录取和性别的频数
crimtab    #3000个男性罪犯左手中指长度和身高关系
HairEyeColor    #592人头发颜色、眼睛颜色和性别的频数
occupationalStatus    #英国男性父子职业联系


类矩阵
eurodist    #欧洲12个城市的距离矩阵,只有下三角部分
Harman23.cor    #305个女孩八个形态指标的相关系数矩阵
Harman74.cor    #145个儿童24个心理指标的相关系数矩阵


数据框
airquality    #纽约1973年5-9月每日空气质量
anscombe    #四组x-y数据,虽有相似的统计量,但实际数据差别较大
attenu    #多个观测站对加利福尼亚23次地震的观测数据
attitude    #30个部门在七个方面的调查结果,调查结果是同一部门35个职员赞成的百分比
beaver1    #一只海狸每10分钟的体温数据,共114条数据
beaver2    #另一只海狸每10分钟的体温数据,共100条数据
BOD    #随水质的提高,生化反应对氧的需求(mg/l)随时间(天)的变化
cars    #1920年代汽车速度对刹车距离的影响
chickwts    #不同饮食种类对小鸡生长速度的影响
esoph    #法国的一个食管癌病例对照研究
faithful    #一个间歇泉的爆发时间和持续时间
Formaldehyde    #两种方法测定甲醛浓度时分光光度计的读数
Freeny     #每季度收入和其他四因素的记录
dating from     #配对的病例对照数据,用于条件logistic回归
InsectSprays     #使用不同杀虫剂时昆虫数目
iris    #3种鸢尾花形态数据
LifeCycleSavings    #50个国家的存款率
longley    #强共线性的宏观经济数据
morley    #光速测量试验数据
mtcars    #32辆汽车在11个指标上的数据
OrchardSprays     #使用拉丁方设计研究不同喷雾剂对蜜蜂的影响
PlantGrowth     #三种处理方式对植物产量的影响
pressure     #温度和气压
Puromycin     #两种细胞中辅因子浓度对酶促反应的影响
quakes     #1000次地震观测数据(震级>4)
randu     #在VMS1.5中使用FORTRAN中的RANDU三个一组生成随机数字,共400组。
rock     #48块石头的形态数据
sleep     #两药物的催眠效果
stackloss     #化工厂将氨转为硝酸的数据
swiss     #瑞士生育率和社会经济指标
ToothGrowth     #VC剂量和摄入方式对豚鼠牙齿的影响
trees    #树木形态指标
USArrests    #美国50个州的四个犯罪率指标
USJudgeRatings    #43名律师的12个评价指标
warpbreaks    #织布机异常数据
women    #15名女性的身高和体重


列表
state.center    #美国50个州中心的经度和纬度


类数据框
ChickWeight    #饮食对鸡生长的影响
CO2    #耐寒植物CO2摄取的差异
DNase    #若干次试验中,DNase浓度和光密度的关系
Indometh    #某药物的药物动力学数据
Loblolly    #火炬松的高度、年龄和种源
Orange    #桔子树生长数据
Theoph    #茶碱药动学数据


时间序列数据
airmiles    #美国1937-1960年客运里程营收(实际售出机位乘以飞行哩数)
AirPassengers    #Box & Jenkins航空公司1949-1960年每月国际航线乘客数
austres    #澳大利亚1971-1994每季度人口数(以千为单位)
BJsales    #有关销售的一个时间序列
BJsales.lead    #前一指标的先行指标(leading indicator)
co2    #1959-1997年每月大气co2浓度(ppm)
discoveries    #1860-1959年每年巨大发现或发明的个数
ldeaths    #1974-1979年英国每月支气管炎、肺气肿和哮喘的死亡率
fdeaths    #前述死亡率的女性部分
mdeaths    #前述死亡率的男性部分
freeny.y    #每季度收入
JohnsonJohnson    #1960-1980年每季度Johnson & Johnson股票的红利
LakeHuron    #1875-1972年某一湖泊水位的记录
lh     #黄体生成素水平,10分钟测量一次
lynx    #1821-1934年加拿大猞猁数据
nhtemp     #1912-1971年每年平均温度
Nile     #1871-1970尼罗河流量
nottem     #1920-1939每月大气温度
presidents     #1945-1974年每季度美国总统支持率
UKDriverDeaths     #1969-1984年每月英国司机死亡或严重伤害的数目
sunspot.month     #1749-1997每月太阳黑子数
sunspot.year     #1700-1988每年太阳黑子数
sunspots    #1749-1983每月太阳黑子数
treering    #归一化的树木年轮数据
UKgas    #1960-1986每月英国天然气消耗
USAccDeaths    #1973-1978美国每月意外死亡人数
uspop    #1790–1970美国每十年一次的人口总数(百万为单位)
WWWusage    #每分钟网络连接数
Seatbelts     #多变量时间序列。和UKDriverDeaths时间段相同,反映更多因素。
EuStockMarkets    #多变量时间序列。欧洲股市四个主要指标的每个工作日记录,共1860条记录。

当然了,如果我们想知道任意一个包自带有哪些数据集,可以有命令:> data(package = '包名')

data(package = 'ggplot2') 

  

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 11 presidents from Eisenhower to
                       Obama
seals                  Vector field of seal movements
txhousing              Housing sales in TX

  

原文地址:https://www.cnblogs.com/adam012019/p/14918647.html