Skip to contents

The data function is used both to load data sets from packages, and give a display of the names and titles of data sets in one or more packages, however it does not return a result that can be easily used to get additional information about the nature of data sets in packages.

The datasets() function is designed to produce a more useful summary display of data sets in one or more packages. It extracts the class and dimension information (dim or codelength) of each item, and formats these to provide additional descriptors.

Usage

datasets(package, 
        allClass=FALSE, 
        incPackage=length(package) > 1,
        maxTitle=NULL)

Arguments

package

a character vector giving the package(s) to look in

allClass

a logical variable. Include all classes of the item (TRUE) or just the last class (FALSE)?

incPackage

include the package name in result?

maxTitle

maximum length of data set Title

Details

The requested packages must be installed, and are silently loaded in order to extract class and size information.

Value

A data.frame whose rows correspond to data sets found in package.

The columns (for a single package) are:

Item

data set name, a character variable

class

class, the object class of the data set, typically one of "data.frame", "table", "array" ...

dim

an abbreviation of the dimensions of the data set, in a form like "36x3" for a data.frame or matrix with 36 rows and 3 columns.

Title

data set title

Author

Michael Friendly, with R-help from Curt Seeliger

Note

In Rmd documents, `datasets("package") |> knitr::kable()` can be used to create a more pleasing display.

See also

Examples

datasets("vcdExtra")
#>              Item      class       dim
#> 1        Abortion      table     2x2x2
#> 2        Accident data.frame      80x5
#> 3        AirCrash data.frame     439x5
#> 4       Alligator data.frame      80x5
#> 5        Asbestos      array       5x4
#> 6        Bartlett      table     2x2x2
#> 7            Burt data.frame      27x3
#> 8          Caesar      table   3x2x2x2
#> 9          Cancer      table     2x2x2
#> 10     Cormorants data.frame     343x8
#> 11  CyclingDeaths data.frame     208x2
#> 12   DaytonSurvey data.frame      32x6
#> 13        Depends      table        15
#> 14      Detergent      table   2x2x2x3
#> 15         Donner data.frame      90x5
#> 16      Draft1970 data.frame     366x3
#> 17 Draft1970table      table      12x3
#> 18           Dyke      table 2x2x2x2x2
#> 19      Fungicide      array   2x2x2x2
#> 20            GSS data.frame       6x3
#> 21       Geissler data.frame      90x4
#> 22          Gilby      table       6x4
#> 23          Glass data.frame      25x3
#> 24   HairEyePlace      array     4x5x2
#> 25       Hauser79 data.frame      25x3
#> 26          Heart      table     2x2x3
#> 27        Heckman      table 2x2x2x2x2
#> 28     HospVisits      table       3x3
#> 29     HouseTasks      table      13x4
#> 30           Hoyt      table   4x3x7x2
#> 31            ICU data.frame    200x22
#> 32         JobSat      table       4x4
#> 33     Mammograms      array       4x4
#> 34         Mental data.frame      24x3
#> 35           Mice data.frame      30x4
#> 36       Mobility      table       5x5
#> 37        PhdPubs data.frame     915x6
#> 38     ShakeWords data.frame     100x2
#> 39             TV      array    5x11x3
#> 40       Titanicp data.frame    1309x6
#> 41       Toxaemia data.frame      60x5
#> 42        Vietnam data.frame      40x4
#> 43       Vote1980 data.frame      28x4
#> 44      WorkerSat data.frame       8x4
#> 45    Yamaguchi87 data.frame      75x4
#>                                                    Title
#> 1                                  Abortion Opinion Data
#> 2             Traffic Accident Victims in France in 1958
#> 3                                         Air Crash Data
#> 4                                  Alligator Food Choice
#> 5                         Effect of Exposure to Asbestos
#> 6                    Bartlett Data on Plum Root Cuttings
#> 7       Burt (1950) Data on Hair, Eyes, Head and Stature
#> 8         Risk Factors for Infection in Caesarian Births
#> 9                     Survival of Breast Cancer Patients
#> 10              Advertising Behavior by Males Cormorants
#> 11                                 London Cycling Deaths
#> 12                Dayton Student Survey on Substance Use
#> 13                            Dependencies of R Packages
#> 14                             Detergent preference data
#> 15                          Survival in the Donner Party
#> 16                           USA 1970 Draft Lottery Data
#> 17                          USA 1970 Draft Lottery Table
#> 18                        Sources of Knowledge of Cancer
#> 19                   Carcinogenic Effects of a Fungicide
#> 20      General Social Survey- Sex and Party affiliation
#> 21                Geissler's Data on the Human Sex Ratio
#> 22          Clothing and Intelligence Rating of Children
#> 23              British Social Mobility from Glass(1954)
#> 24    Hair Color and Eye Color in Caithness and Aberdeen
#> 25                 Hauser (1979) Data on Social Mobility
#> 26                     Sex, Occupation and Heart Disease
#> 27 Labour Force Participation of Married Women 1967-1971
#> 28                                  Hospital Visits Data
#> 29       Household Tasks Performed by Husbands and Wives
#> 30                       Minnesota High School Graduates
#> 31                                          ICU data set
#> 32    Cross-classification of job satisfaction by income
#> 33                                     Mammogram Ratings
#> 34                     Mental Impairment and Parents SES
#> 35                                   Mice Depletion Data
#> 36                                  Social Mobility data
#> 37                        Publications of PhD Candidates
#> 38                   Shakespeare's Word Type Frequencies
#> 39                                       TV Viewing Data
#> 40                             Passengers on the Titanic
#> 41                        Toxaemia Symptoms in Pregnancy
#> 42                 Student Opinion about the Vietnam War
#> 43       Race and Politics in the 1980 Presidential Vote
#> 44                              Worker Satisfaction Data
#> 45              Occupational Mobility in Three Countries
# datasets(c("vcd", "vcdExtra"))
datasets("datasets", maxTitle=50)
#>                       Item      class     dim
#> 1            AirPassengers         ts     144
#> 2                  BJsales         ts     150
#> 3   BJsales.lead (BJsales)         ts     150
#> 4                      BOD data.frame     6x2
#> 5                      CO2 data.frame    84x5
#> 6              ChickWeight data.frame   578x4
#> 7                    DNase data.frame   176x3
#> 8           EuStockMarkets     matrix  1860x4
#> 9             Formaldehyde data.frame     6x2
#> 10            HairEyeColor      table   4x4x2
#> 11            Harman23.cor       list       3
#> 12            Harman74.cor       list       3
#> 13                Indometh data.frame    66x3
#> 14            InsectSprays data.frame    72x2
#> 15          JohnsonJohnson         ts      84
#> 16               LakeHuron         ts      98
#> 17        LifeCycleSavings data.frame    50x5
#> 18                Loblolly data.frame    84x3
#> 19                    Nile         ts     100
#> 20                  Orange data.frame    35x3
#> 21           OrchardSprays data.frame    64x4
#> 22             PlantGrowth data.frame    30x2
#> 23               Puromycin data.frame    23x3
#> 24               Seatbelts         ts   192x8
#> 25                  Theoph data.frame   132x5
#> 26                 Titanic      table 4x2x2x2
#> 27             ToothGrowth data.frame    60x3
#> 28           UCBAdmissions      table   2x2x6
#> 29          UKDriverDeaths         ts     192
#> 30                   UKgas         ts     108
#> 31             USAccDeaths         ts      72
#> 32               USArrests data.frame    50x4
#> 33          USJudgeRatings data.frame   43x12
#> 34   USPersonalExpenditure      array     5x5
#> 35               UScitiesD       dist      45
#> 36                VADeaths      array     5x4
#> 37                WWWusage         ts     100
#> 38             WorldPhones      array     7x7
#> 39             ability.cov       list       3
#> 40                airmiles         ts      24
#> 41              airquality data.frame   153x6
#> 42                anscombe data.frame    11x8
#> 43                  attenu data.frame   182x5
#> 44                attitude data.frame    30x7
#> 45                 austres         ts      89
#> 46       beaver1 (beavers) data.frame   114x4
#> 47       beaver2 (beavers) data.frame   100x4
#> 48                    cars data.frame    50x2
#> 49                chickwts data.frame    71x2
#> 50                     co2         ts     468
#> 51                 crimtab      table   42x22
#> 52             discoveries         ts     100
#> 53                   esoph data.frame    88x5
#> 54                    euro    numeric      11
#> 55       euro.cross (euro)      array   11x11
#> 56                eurodist       dist     210
#> 57                faithful data.frame   272x2
#> 58  fdeaths (UKLungDeaths)         ts      72
#> 59                  freeny data.frame    39x5
#> 60       freeny.x (freeny)      array    39x4
#> 61       freeny.y (freeny)         ts      39
#> 62                  infert data.frame   248x8
#> 63                    iris data.frame   150x5
#> 64                   iris3      array  50x4x3
#> 65                 islands    numeric      48
#> 66  ldeaths (UKLungDeaths)         ts      72
#> 67                      lh         ts      48
#> 68                 longley data.frame    16x7
#> 69                    lynx         ts     114
#> 70  mdeaths (UKLungDeaths)         ts      72
#> 71                  morley data.frame   100x3
#> 72                  mtcars data.frame   32x11
#> 73                  nhtemp         ts      60
#> 74                  nottem         ts     240
#> 75                     npk data.frame    24x5
#> 76      occupationalStatus      table     8x8
#> 77                  precip    numeric      70
#> 78              presidents         ts     120
#> 79                pressure data.frame    19x2
#> 80                  quakes data.frame  1000x5
#> 81                   randu data.frame   400x3
#> 82                  rivers    numeric     141
#> 83                    rock data.frame    48x4
#> 84                   sleep data.frame    20x3
#> 85  stack.loss (stackloss)    numeric      21
#> 86     stack.x (stackloss)      array    21x3
#> 87               stackloss data.frame    21x4
#> 88       state.abb (state)  character      50
#> 89      state.area (state)    numeric      50
#> 90    state.center (state)       list       2
#> 91  state.division (state)     factor      50
#> 92      state.name (state)  character      50
#> 93    state.region (state)     factor      50
#> 94       state.x77 (state)      array    50x8
#> 95           sunspot.month         ts    3177
#> 96            sunspot.year         ts     289
#> 97                sunspots         ts    2820
#> 98                   swiss data.frame    47x6
#> 99                treering         ts    7980
#> 100                  trees data.frame    31x3
#> 101                  uspop         ts      19
#> 102                volcano      array   87x61
#> 103             warpbreaks data.frame    54x3
#> 104                  women data.frame    15x2
#>                                                  Title
#> 1          Monthly Airline Passenger Numbers 1949-1960
#> 2                    Sales Data with Leading Indicator
#> 3                    Sales Data with Leading Indicator
#> 4                            Biochemical Oxygen Demand
#> 5                Carbon Dioxide Uptake in Grass Plants
#> 6       Weight versus age of chicks on different diets
#> 7                                 Elisa assay of DNase
#> 8   Daily Closing Prices of Major European Stock Indic
#> 9                        Determination of Formaldehyde
#> 10           Hair and Eye Color of Statistics Students
#> 11                                  Harman Example 2.3
#> 12                                  Harman Example 7.4
#> 13                    Pharmacokinetics of Indomethacin
#> 14                      Effectiveness of Insect Sprays
#> 15      Quarterly Earnings per Johnson & Johnson Share
#> 16                       Level of Lake Huron 1875-1972
#> 17                Intercountry Life-Cycle Savings Data
#> 18                       Growth of Loblolly pine trees
#> 19                              Flow of the River Nile
#> 20                              Growth of Orange Trees
#> 21                           Potency of Orchard Sprays
#> 22          Results from an Experiment on Plant Growth
#> 23          Reaction Velocity of an Enzymatic Reaction
#> 24            Road Casualties in Great Britain 1969-84
#> 25                    Pharmacokinetics of Theophylline
#> 26               Survival of passengers on the Titanic
#> 27  The Effect of Vitamin C on Tooth Growth in Guinea 
#> 28                   Student Admissions at UC Berkeley
#> 29            Road Casualties in Great Britain 1969-84
#> 30                        UK Quarterly Gas Consumption
#> 31               Accidental Deaths in the US 1973-1978
#> 32                     Violent Crime Rates by US State
#> 33  Lawyers' Ratings of State Judges in the US Superio
#> 34                           Personal Expenditure Data
#> 35  Distances Between European Cities and Between US C
#> 36                      Death Rates in Virginia (1940)
#> 37                           Internet Usage per Minute
#> 38                              The World's Telephones
#> 39                      Ability and Intelligence Tests
#> 40  Passenger Miles on Commercial US Airlines, 1937-19
#> 41                   New York Air Quality Measurements
#> 42  Anscombe's Quartet of 'Identical' Simple Linear Re
#> 43                   The Joyner-Boore Attenuation Data
#> 44                  The Chatterjee-Price Attitude Data
#> 45  Quarterly Time Series of the Number of Australian 
#> 46              Body Temperature Series of Two Beavers
#> 47              Body Temperature Series of Two Beavers
#> 48                Speed and Stopping Distances of Cars
#> 49                        Chicken Weights by Feed Type
#> 50             Mauna Loa Atmospheric CO2 Concentration
#> 51                       Student's 3000 Criminals Data
#> 52             Yearly Numbers of Important Discoveries
#> 53           Smoking, Alcohol and (O)esophageal Cancer
#> 54                 Conversion Rates of Euro Currencies
#> 55                 Conversion Rates of Euro Currencies
#> 56  Distances Between European Cities and Between US C
#> 57                            Old Faithful Geyser Data
#> 58         Monthly Deaths from Lung Diseases in the UK
#> 59                               Freeny's Revenue Data
#> 60                               Freeny's Revenue Data
#> 61                               Freeny's Revenue Data
#> 62  Infertility after Spontaneous and Induced Abortion
#> 63                          Edgar Anderson's Iris Data
#> 64                          Edgar Anderson's Iris Data
#> 65               Areas of the World's Major Landmasses
#> 66         Monthly Deaths from Lung Diseases in the UK
#> 67                Luteinizing Hormone in Blood Samples
#> 68                  Longley's Economic Regression Data
#> 69            Annual Canadian Lynx trappings 1821-1934
#> 70         Monthly Deaths from Lung Diseases in the UK
#> 71                       Michelson Speed of Light Data
#> 72                          Motor Trend Car Road Tests
#> 73            Average Yearly Temperatures in New Haven
#> 74  Average Monthly Temperatures at Nottingham, 1920-1
#> 75              Classical N, P, K Factorial Experiment
#> 76       Occupational Status of Fathers and their Sons
#> 77                   Annual Precipitation in US Cities
#> 78         Quarterly Approval Ratings of US Presidents
#> 79  Vapor Pressure of Mercury as a Function of Tempera
#> 80                   Locations of Earthquakes off Fiji
#> 81    Random Numbers from Congruential Generator RANDU
#> 82              Lengths of Major North American Rivers
#> 83              Measurements on Petroleum Rock Samples
#> 84                                Student's Sleep Data
#> 85                    Brownlee's Stack Loss Plant Data
#> 86                    Brownlee's Stack Loss Plant Data
#> 87                    Brownlee's Stack Loss Plant Data
#> 88                          US State Facts and Figures
#> 89                          US State Facts and Figures
#> 90                          US State Facts and Figures
#> 91                          US State Facts and Figures
#> 92                          US State Facts and Figures
#> 93                          US State Facts and Figures
#> 94                          US State Facts and Figures
#> 95        Monthly Sunspot Data, from 1749 to "Present"
#> 96                      Yearly Sunspot Data, 1700-1988
#> 97                  Monthly Sunspot Numbers, 1749-1983
#> 98  Swiss Fertility and Socioeconomic Indicators (1888
#> 99                    Yearly Treering Data, -6000-1979
#> 100 Diameter, Height and Volume for Black Cherry Trees
#> 101              Populations Recorded by the US Census
#> 102 Topographic Information on Auckland's Maunga Whau 
#> 103        The Number of Breaks in Yarn during Weaving
#> 104     Average Heights and Weights for American Women

# just list dataset names in a package
datasets("vcdExtra")[,"Item"]
#>  [1] "Abortion"       "Accident"       "AirCrash"       "Alligator"     
#>  [5] "Asbestos"       "Bartlett"       "Burt"           "Caesar"        
#>  [9] "Cancer"         "Cormorants"     "CyclingDeaths"  "DaytonSurvey"  
#> [13] "Depends"        "Detergent"      "Donner"         "Draft1970"     
#> [17] "Draft1970table" "Dyke"           "Fungicide"      "GSS"           
#> [21] "Geissler"       "Gilby"          "Glass"          "HairEyePlace"  
#> [25] "Hauser79"       "Heart"          "Heckman"        "HospVisits"    
#> [29] "HouseTasks"     "Hoyt"           "ICU"            "JobSat"        
#> [33] "Mammograms"     "Mental"         "Mice"           "Mobility"      
#> [37] "PhdPubs"        "ShakeWords"     "TV"             "Titanicp"      
#> [41] "Toxaemia"       "Vietnam"        "Vote1980"       "WorkerSat"     
#> [45] "Yamaguchi87"   
datasets("vcd")[,"Item"]
#>  [1] "Arthritis"       "Baseball"        "BrokenMarriage"  "Bundesliga"     
#>  [5] "Bundestag2005"   "Butterfly"       "CoalMiners"      "DanishWelfare"  
#>  [9] "Employment"      "Federalist"      "Hitters"         "HorseKicks"     
#> [13] "Hospital"        "JobSatisfaction" "JointSports"     "Lifeboats"      
#> [17] "MSPatients"      "NonResponse"     "OvaryCancer"     "PreSex"         
#> [21] "Punishment"      "RepVict"         "Rochdale"        "Saxony"         
#> [25] "SexualFun"       "SpaceShuttle"    "Suicide"         "Trucks"         
#> [29] "UKSoccer"        "VisualAcuity"    "VonBort"         "WeldonDice"     
#> [33] "WomenQueue"