如何获取R或R包中可用的数据集列表?

基本R和不同R包中有许多数据集。这些数据集的特性非常不同,例如,一些数据集是时间序列数据,一些数据集只有数字列,一些数据集包含数值和因数列,有些包含字符列,而其他类型的列。因此,它对想要学习R编程使用的每个人都很有帮助。要获得基数R中可用数据集的列表,我们可以使用,data()但要获取包中可用数据集的列表,我们首先需要加载该包,然后data()命令显示该包中的可用数据集。同样,对于基数R中的数据集,我们可以使用ls(“ package:datasets”)。

示例

> data()

输出结果

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

示例

> ls("package:datasets")

输出结果

[1] "ability.cov"       "airmiles"    "AirPassengers"

[4] "airquality"       "anscombe"       "attenu"

[7] "attitude"          "austres"       "beaver1"

[10] "beaver2"       "BJsales"       "BJsales.lead"

[13] "BOD"             "cars"          "ChickWeight"

[16] "chickwts"          "co2"          "CO2"

[19] "crimtab"       "discoveries"       "DNase"

[22] "esoph"          "euro"          "euro.cross"

[25] "eurodist"    "EuStockMarkets"    "faithful"

[28] "fdeaths"    "Formaldehyde"       "freeny"

[31] "freeny.x"    "freeny.y"          "HairEyeColor"

[34] "Harman23.cor" "Harman74.cor"    "Indometh"

[37] "infert"       "InsectSprays"       "iris"

[40] "iris3"       "islands"       "JohnsonJohnson"

[43] "LakeHuron"    "ldeaths"          "lh"

[46] "LifeCycleSavings" "Loblolly"    "longley"

[49] "lynx"          "mdeaths"       "morley"

[52] "mtcars"       "nhtemp"          "Nile"

[55] "nottem"       "npk"       "occupationalStatus"

[58] "Orange"    "OrchardSprays"    "PlantGrowth"

[61] "precip"    "presidents"       "pressure"

[64] "Puromycin"    "quakes"       "randu"

[67] "rivers"          "rock"       "Seatbelts"

[70] "sleep"       "stack.loss"       "stack.x"

[73] "stackloss"    "state.abb"       "state.area"

[76] "state.center" "state.division" "state.name"

[79] "state.region" "state.x77"       "sunspot.month"

[82] "sunspot.year"    "sunspots"        "swiss"

[85] "Theoph"       "Titanic"       "ToothGrowth"

[88] "treering"       "trees"       "UCBAdmissions"

[91] "UKDriverDeaths" "UKgas"       "USAccDeaths"

[94] "USArrests"    "UScitiesD"       "USJudgeRatings"

[97] "USPersonalExpenditure" "uspop"    "VADeaths"

[100] "volcano"       "warpbreaks"       "women"

[103] "WorldPhones"    "WWWusage"

要查看包中的数据集,我们需要加载包,然后使用data()。这样,我们将在窗口底部找到一个包中可用的数据集列表,该窗口显示了基数R中的所有数据集。

示例

> library(ggplot2)

> data()

输出结果

Data sets in package ‘ggplot2’:

diamonds       Prices of 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 and 2008 for 38

               popular models of car

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

现在,我们可以使用ggplot2软件包的任何数据集,例如查看msleep数据的顶部行-

示例

> head(msleep)

# A tibble: 6 x 11

输出结果

name genus vore order conservation sleep_total sleep_rem sleep_cycle awake

<chr> <chr> <chr> <chr> <chr>       <dbl>    <dbl> <dbl> <dbl>

1 Chee~ Acin~ carni Carn~ lc          12.1    NA    NA    11.9

2 Owl ~ Aotus omni Prim~ <NA>          17    1.8    NA    7

3 Moun~ Aplo~ herbi Rode~ nt          14.4    2.4    NA    9.6

4 Grea~ Blar~ omni Sori~ lc          14.9    2.3    0.133    9.1

5 Cow Bos herbi Arti~ domesticated    4       0.7    0.667    20

6 Thre~ Brad~ herbi Pilo~ <NA>       14.4    2.2    0.767    9.6

# ... with 2 more variables: brainwt <dbl>, bodywt <dbl>

以上是 如何获取R或R包中可用的数据集列表? 的全部内容, 来源链接: utcz.com/z/338111.html

回到顶部