Learn R Programming

openintro

Supplemental functions and data for OpenIntro resources, which includes open-source textbooks and resources for introductory statistics at openintro.org. The package contains data sets used in our open-source textbooks along with custom plotting functions for reproducing book figures. The package also contains the datasets used in OpenIntro labs. Note that many functions and examples include color transparency; some plotting elements may not show up properly (or at all) when run in some versions of Windows operating system.

Installation

You can install the released version of openintro from CRAN with:

install.packages("openintro")

You can install the development version of openintro from GitHub with:

# install.packages("devtools")
library(devtools)
install_github("OpenIntroStat/openintro")

This package was produced as part of the OpenIntro project. For the accompanying textbook, visit openintro.org. A PDF of the textbook is free and paperbacks can be purchased online (royalty-free).

Questions, bugs, feature requests

You can file an issue to get help, report a bug, or make a feature request.

When filing an issue to get help or report a bug, please make a minimal reproducible example using the reprex package. If you haven’t heard of or used reprex before, you’re in for a treat! Seriously, reprex will make all of your R-question-asking endeavors easier (which is a pretty insane ROI for the five to ten minutes it’ll take you to learn what it’s all about). For additional reprex pointers, check out the Get help! section of the tidyverse site.

Before opening a new issue, be sure to search issues and pull requests to make sure the bug hasn’t been reported and/or already fixed in the development version. By default, the search will be pre-populated with is:issue is:open. You can edit the qualifiers (e.g. is:pr, is:closed) as needed. For example, you’d simply remove is:open to search all issues in the repo, open or closed.

Contributing

Process for adding new data to the package

The following steps use the devtools and usethis packages for various steps. We recommend using this process when suggesting new datasets to be added to the package. If the dataset is large (>500MB) or you’d like to add a function, please open an issue first for discussion before making the pull request.

  1. Fork and clone the repo with usethis::create_from_github("OpenIntroStat/openintro")
    • Note: If you have write access to the repo, you can skip this step.
  2. Start a new pull request with usethis::pr_init("BRANCH-NAME"), where BRANCH-NAME is an informative branch name.
  3. If adding a file that is not an .rda file to begin with (Excel, csv, etc.), create a folder in the data-raw folder with the name of the dataset (how you’d like it to show up in the package). Please use snake_case for naming, e.g. name_of_dataset.
  4. Place your dataset in its raw form in the folder.
  5. Also in the data-raw folder, create a new R script called name_of_dataset-dataprep.R and write the code needed to read in the file, make any modifications to the data that are needed (if any), and end with usethis::use_data() to save the data in the package as an .rda file with the ideal compression. See examples from other folders in data-raw for sample code. The contents of this folder do not end up in the package (the entire folder is ignored in the .Rbuildignore) so you don’t need to worry about adding package dependencies etc.
  6. In the R folder, create an R script called data-name_of_dataset and add documentation using Roxygen style. See other documentation files for help with style. In the examples, use tidyverse syntax but do not use library(tidyverse) and only use the relevant packages, e.g. library(dplyr), library(ggplot2).
  7. Restart R and run devtools::load_all() to make sure the data loads and run your examples to confirm they all work.
  8. Run devtools::document(), restart R, and then devtools::load_all(). Then, check out ?name_of_dataset to make sure the documentation looks as expected.
  9. Run devtools::check(). The only NOTE you should see as a result of the check should be about the package size. If any other ERRORs, NOTEs, or WARNINGs are generated, resolve them or open an issue for help.
  10. In the pkgdown.yml file, add the name of the dataset under reference, in the correct alphabetical order.
  11. Add a note in the NEWS.md with the new dataset you’ve added with a link to your GitHub username so we can acknowledge your contribution, e.g. “added by @mine-cetinkaya-rundel”.

Code of Conduct

Please note that the openintro project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Copy Link

Version

Install

install.packages('openintro')

Monthly Downloads

12,024

Version

2.4.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Last Published

September 1st, 2022

Functions in openintro (2.4.0)

COL

OpenIntro Statistics colors
CT2DF

Contingency Table to Data Frame
ChiSquareTail

Plot upper tail in chi-square distribution
IMSCOL

Introduction to Modern Statistics (IMS) Colors
AxisInDollars

Build Better Looking Axis Labels for US Dollars
ArrowLines

Create a Line That may have Arrows on the Ends
Braces

Plot a Braces Symbol
AxisInPercent

Build Better Looking Axis Labels for Percentages
BG

Add background color to a plot
antibiotics

Pre-existing conditions in 92 children
CCP

Plot a Cartesian Coordinate Plane
ami_occurrences

Acute Myocardial Infarction (Heart Attack) Events
age_at_mar

Age at first marriage of 5,534 US women.
ames

Housing prices in Ames, Iowa
ball_bearing

Lifespan of ball bearings
bdims

Body measurements of 507 physically active individuals.
acs12

American Community Survey, 2012
absenteeism

Absenteeism from school in New South Wales
bac

Beer and blood alcohol content
babies_crawl

Crawling age
MosaicPlot

Custom Mosaic Plot
PlotWLine

Plot data and add a regression line
avandia

Cardiovascular problems for two types of Diabetes medicines
babies

The Child Health and Development Studies
boxPlot

Box plot
ask

How important is it to ask pointed questions?
biontech_adolescents

Efficacy of Pfizer-BioNTech COVID-19 vaccine on adolescents
arbuthnot

Male and female births in London
assortive_mating

Eye color of couples
association

Simulated data for association plots
births

North Carolina births, 100 cases
birds

Aircraft-Wildlife Collisions
cars93

cars93
buildAxis

Axis function substitute
blizzard_salary

Blizzard Employee Voluntary Salary Info.
births14

US births
china

Child care hours
classdata

Simulated class data
children_gender_stereo

Gender Stereotypes in 5-7 year old Children
cia_factbook

CIA Factbook Details on Countries
cchousing

Community college housing (simulated data)
climber_drugs

Climber Drugs Data.
burger

Burger preferences
books

Sample of books on a shelf
census

Random sample of 2000 U.S. Census Data
cherry

Summary information for 31 cherry trees
cards

Deck of cards
cancer_in_dogs

Cancer in dogs
cpu

CPU's Released between 2010 and 2020.
cle_sac

Cleveland and Sacramento
daycare_fines

Daycare fines
ebola_survey

Survey on Ebola quarantine
climate70

Temperature Summary Data, Geography Limited
calc_streak

Calculate hit streaks
dotPlot

Dot plot
corr_match

Sample data sets for correlation problems
earthquakes

Earthquakes
coast_starlight

Coast Starlight Amtrak train
contTable

Generate Contingency Tables for LaTeX
credits

College credits.
dotPlotStack

Add a Stacked Dot Plot to an Existing Plot
email

Data frame representing information about a collection of emails
edaPlot

Exploratory data analysis plot
densityPlot

Density plot
fadeColor

Fade colors
family_college

Simulated sample of parent / teen college attendance
email50

Sample of 50 emails
exam_grades

Exam and course grades for statistics students
elmhurst

Elmhurst College gift aid
cpr

CPR data set
drone_blades

Quadcopter Drone Blades
dream

Survey on views of the DREAM Act
country_iso

Country ISO information
fcid

Summary of male heights from USDA Food Commodity Intake Database
fastfood

Nutrition in fast food
diabetes2

Type 2 Diabetes Clinical Trial for Patients 10-17 Years Old
dlsegments

Create a Double Line Segment Plot
duke_forest

Sale prices of houses in Duke Forest, Durham, NC
env_regulation

American Adults on Regulation and Renewable Energy
drug_use

Drug use of students and parents
exams

Exam scores
ethanol

Ethanol Treatment for Tumors Experiment
evals

Professor evaluations and beauty
friday

Friday the 13th
get_it_dunn_run

Get it Dunn Run, Race Times
flow_rates

River flow data
exclusive_relationship

Number of Exclusive Relationships
fact_opinion

Can Americans categorize facts and opinions?
health_coverage

Health Coverage and Health Status
helium

Helium football
epa2021

Vehicle info from the EPA for 2021
full_body_scan

Poll about use of full-body airport scanners
hsb2

High School and Beyond survey
epa2012

Vehicle info from the EPA for 2012
gss2010

2010 General Social Survey
loop

Output a message while inside a loop
jury

Simulated juror data set
kobe_basket

Kobe Bryant basketball performance
lab_report

lab_report
london_murders

London Murders, 2006-2011
midterms_house

President's party performance and unemployment rate
helmet

Socioeconomic status and reduced-fee school lunches
labor_market_discriminiation

Are Emily and Greg More Employable Than Lakisha and Jamal?
gdp_countries

GDP Countries Data.
esi

Environmental Sustainability Index 2005
global_warming_pew

Pew survey on global warming
healthcare_law_survey

Pew Research Center poll on health care, including question variants
goog

Google stock data
heart_transplant

Heart Transplant Data
lizard_habitat

Field data on lizards observed in their natural habitat
linResPlot

Create simple regression plot with residual plot
house

United States House of Representatives historical make-up
gifted

Analytical skills of young gifted children
husbands_wives

Great Britain: husband and wife pairs
gradestv

Simulated data for analyzing the relationship between watching TV and grades
gsearch

Simulated Google search experiment
lizard_run

Lizard speeds
housing

Simulated data set on student housing
law_resume

Gender, Socioeconomic Class, and Interview Invites
migraine

Migraines and acupuncture
gpa

Survey of Duke students on GPA, studying, and more
gov_poll

Pew Research poll on government approval ratings
mn_police_use_of_force

Minneapolis police use of force data.
mail_me

Influence of a Good Mood on Helpfulness
male_heights_fcid

Random sample of adult male heights
ipo

Facebook, Google, and LinkedIn IPO filings
lsegments

Create a Line Segment Plot
nba_players_19

NBA Players for the 2018-2019 season
hfi

Human Freedom Index
mammals

Sleep in Mammals
fheights

Female college student heights, in inches
mlbbat10

Major League Baseball Player Hitting Statistics for 2010
mtl

Medial temporal lobe (MTL) and other data for 26 participants
fish_oil_18

Findings on n-3 Fatty Acid Supplement Health Benefits
ncbirths

North Carolina births, 1000 cases
lmPlot

Linear regression plot with residual plot
normTail

Normal distribution tails
nuclear_survey

Nuclear Arms Reduction Survey
murders

Data for 20 metropolitan areas
playing_cards

Table of Playing Cards in 52-Card Deck
ipod

Length of songs on an iPod
pm25_2011_durham

Air quality for Durham, NC
gender_discrimination

Bank manager recommendations based on gender
histPlot

Histogram or hollow histogram
penetrating_oil

What's the best way to loosen a rusty bolt?
gpa_study_hours

gpa_study_hours
gpa_iq

Sample of students and their GPA and IQ
penelope

Guesses at the weight of Penelope (a cow)
leg_mari

Legalization of Marijuana Support in 2010 California Survey
mariokart

Wii Mario Kart auctions from Ebay
gear_company

Fake data for a gear company example
immigration

Poll on illegal workers in the US
res_demo_1

Simulated data for regression
major_survey

Survey of Duke students and the area of their major
infmortrate

Infant Mortality Rates, 2012
makeTube

Regression tube
mcu_films

Marvel Cinematic Universe films
res_demo_2

Simulated data for regression
seattlepets

Names of pets in Seattle
sex_discrimination

Bank manager recommendations based on sex
myPDF

Custom PDF function
mlb_teams

Major League Baseball Teams Data.
marathon

New York City Marathon Times (outdated)
mammogram

Experiment with Mammogram Randomized
mlb_players_18

Batter Statistics for 2018 Major League Baseball (MLB) Season
penny_ages

Penny Ages
openintro_cols

Function to extract OpenIntro IMS colors as hex codes
oscars

Oscar winners, 1929 to 2018
photo_classify

Photo classifications: fashion or not
nba_heights

NBA Player heights from 2008-9
outliers

Simulated data sets for different types of outliers
openintro_colors

OpenIntro colors
piracy

Piracy and PIPA/SOPA
student_housing

Community college housing (simulated data, 2015)
loans_full_schema

Loan data from Lending Club
pew_energy_2018

Pew Survey on Energy Sources in 2018
sa_gdp_elec

Sustainability and Economic Indicators for South Africa.
president

United States Presidental History
russian_influence_on_us_election_2016

Russians' Opinions on US Election Influence in 2016
poker

Poker winnings during 50 sessions
possum

Possums in Australia and New Guinea
race_justice

Yahoo! News Race and Justice poll results
snowfall

Snowfall at Paradise, Mt. Rainier National Park
satgpa

SAT and GPA data
scale_color_openintro

Color scale constructor for OpenIntro IMS colors
rosling_responses

Sample Responses to Two Public Health Questions
prison

Prison isolation experiment
resume

Which resume attributes drive job callbacks?
socialexp

Social experiment
sp500_1950_2018

Daily observations for the S&P 500
malaria

Malaria Vaccine Trial
sp500

Financial information for 50 S&P 500 companies
london_boroughs

London Borough Boundaries
reddit_finance

Reddit Survey on Financial Independence.
opportunity_cost

Opportunity cost of purchases
nyc_marathon

New York City Marathon Times
scotus_healthcare

Public Opinion with SCOTUS ruling on American Healthcare Act
nycflights

Flights data
scale_fill_openintro

Fill scale constructor for OpenIntro IMS colors
orings

1986 Challenger disaster and O-rings
smallpox

Smallpox vaccine results
stats_scores

Final exam scores for twenty students
stem_cell

Embryonic stem cells to treat heart attack (in sheep)
smoking

UK Smoking Data
male_heights

Sample of 100 male heights
stent30

Stents for the treatment of stroke
stocks_18

Monthly Returns for a few stocks
treeDiag

Construct tree diagrams
student_sleep

Sleep for 110 students (simulated)
sulphinpyrazone

Treating heart attacks
sinusitis

Sinusitis and antibiotic experiment
winery_cars

Time Between Gondola Cars at Sterling Winery
sleep_deprivation

Survey on sleep deprivation and transportation workers
supreme_court

Supreme Court approval rating
offshore_drilling

California poll on drilling off the California coast
mlb

Salary data for Major League Baseball (2010)
ucla_f18

UCLA courses in Fall 2018
toy_anova

Simulated data set for ANOVA
transplant

Transplant consultant success rate (fake data)
world_pop

World Population Data.
military

US Military Demographics
sowc_demographics

SOWC Demographics Data.
unempl

Annual unemployment since 1890
sowc_maternal_newborn

SOWC Maternal and Newborn Health Data.
tips

Tip data
thanksgiving_spend

Thanksgiving spending, simulated based on Gallup poll.
openintro_pal

Return function to interpolate an OpenIntro IMS color palette
openintro-package

openintro: Data Sets and Supplemental Functions from 'OpenIntro' Textbooks and Labs
openintro_palettes

OpenIntro palettes
ppp_201503

US Poll on who it is better to raise taxes on
salinity

Salinity in Bimini Lagoon, Bahamas
present

Birth counts
prius_mpg

User reported fuel efficiency for 2017 Toyota Prius Prime
yawn

Contagiousness of yawning
unemploy_pres

President's party performance and unemployment rate
simulated_normal

Simulated data sets, drawn from a normal distribution.
sat_improve

Simulated data for SAT score improvement
sp500_seq

S&P 500 stock data
qqnormsim

Generate simulated QQ plots
simulated_scatter

Simulated data for sample scatterplots
simpsons_paradox_covid

Simpson's Paradox: Covid
sowc_child_mortality

SOWC Child Mortality Data.
simulated_dist

Simulated data sets, not necessarily drawn from a normal distribution.
solar

Energy Output From Two Solar Arrays in San Francisco
yrbss

Youth Risk Behavior Surveillance System (YRBSS)
ucla_textbooks_f18

Sample of UCLA course textbooks for Fall 2018
ssd_speed

SSD read and write speeds
teacher

Teacher Salaries in St. Louis, Michigan
starbucks

Starbucks nutrition
speed_gender_height

Speed, gender, and height of 1325 students
textbooks

Textbook data for UCLA Bookstore and Amazon
ukdemo

United Kingdom Demographic Data
yrbss_samp

Sample of Youth Risk Behavior Surveillance System (YRBSS)
toohey

Simulated polling data set
xom

Exxon Mobile stock data
write_pkg_data

Create a CSV variant of .rda files
tourism

Turkey tourism