- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the list of data sets available in base R or in a package in R?
There are many data sets available in base R and in different packages of R. The characteristics of these data sets are very different, for example, some data sets are time series data, some have only numerical columns, some have numerical as well as factor columns, some includes character columns with other type of columns. Therefore, it becomes helpful to everyone who want to learn the use of R programming. To get the list of available data sets in base R we can use data() but to get the list of data sets available in a package we first need to load that package then data() command shows the available data sets in that package. Also, for data sets in base R, we can use ls("package: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
 "ability.cov" "airmiles" "AirPassengers"  "airquality" "anscombe" "attenu"  "attitude" "austres" "beaver1"  "beaver2" "BJsales" "BJsales.lead"  "BOD" "cars" "ChickWeight"  "chickwts" "co2" "CO2"  "crimtab" "discoveries" "DNase"  "esoph" "euro" "euro.cross"  "eurodist" "EuStockMarkets" "faithful"  "fdeaths" "Formaldehyde" "freeny"  "freeny.x" "freeny.y" "HairEyeColor"  "Harman23.cor" "Harman74.cor" "Indometh"  "infert" "InsectSprays" "iris"  "iris3" "islands" "JohnsonJohnson"  "LakeHuron" "ldeaths" "lh"  "LifeCycleSavings" "Loblolly" "longley"  "lynx" "mdeaths" "morley"  "mtcars" "nhtemp" "Nile"  "nottem" "npk" "occupationalStatus"  "Orange" "OrchardSprays" "PlantGrowth"  "precip" "presidents" "pressure"  "Puromycin" "quakes" "randu"  "rivers" "rock" "Seatbelts"  "sleep" "stack.loss" "stack.x"  "stackloss" "state.abb" "state.area"  "state.center" "state.division" "state.name"  "state.region" "state.x77" "sunspot.month"  "sunspot.year" "sunspots" "swiss"  "Theoph" "Titanic" "ToothGrowth"  "treering" "trees" "UCBAdmissions"  "UKDriverDeaths" "UKgas" "USAccDeaths"  "USArrests" "UScitiesD" "USJudgeRatings"  "USPersonalExpenditure" "uspop" "VADeaths"  "volcano" "warpbreaks" "women"  "WorldPhones" "WWWusage"
To view the data sets in a package we need to load the package and then use data(). In this way, we will find the list of the data sets available in a package at the bottom of the window that shows all the data sets in base 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
Now we can use any data set of ggplot2 package, for example viewing the top rows of msleep data −
> 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>
- How to get the list of available data frames in R environment?
- How to get the list of packages installed in base R?
- What are the different types of point available in geom_point of ggplot2 package in R?
- How to detach a package in R?
- How to extract columns of a data frame in R using dplyr package?
- How to create a column of log with base 2 in data frames stored in R list?
- How to create a column of log with base 10 in data frames stored in R list?
- How to add a rank column in base R of a data frame?
- How to create boxplot for a list object in base R?
- How to find the name of the author of a package in R?
- How to find the functions inside a package in R?
- How to make list of data frames in R?
- How to change the resolution of a plot in base R?
- How to create scatterplot by standardizing the columns of a data frame in base R?
- How to extract the column from a list of data frames in R?