Learn R Programming

⚠️There's a newer version (2.4.0) of this package.Take me there.

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

8,738

Version

2.2.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Mine <c3><87>etinkaya-Rundel

Last Published

June 22nd, 2021

Functions in openintro (2.2.0)

AxisInDollars

Build Better Looking Axis Labels for US Dollars
ChiSquareTail

Plot upper tail in chi-square distribution
Braces

Plot a Braces Symbol
AxisInPercent

Build Better Looking Axis Labels for Percentages
IMSCOL

Introduction to Modern Statistics (IMS) Colors
BG

Add background color to a plot
ArrowLines

Create a Line That may have Arrows on the Ends
COL

OpenIntro Statistics colors
CCP

Plot a Cartesian Coordinate Plane
absenteeism

Absenteeism from school in New South Wales
PlotWLine

Plot data and add a regression line
MosaicPlot

Custom Mosaic Plot
arbuthnot

Male and female births in London
association

Simulated data for association plots
ask

How important is it to ask pointed questions?
assortive_mating

Eye color of couples
calc_streak

Calculate hit streaks
acs12

American Community Survey, 2012
babies

The Child Health and Development Studies
babies_crawl

Crawling age
ami_occurrences

Acute Myocardial Infarction (Heart Attack) Events
cchousing

Community college housing (simulated data)
cancer_in_dogs

Cancer in dogs
census

Random sample of 2000 U.S. Census Data
CT2DF

Contingency Table to Data Frame
ames

Housing prices in Ames, Iowa
cpu

CPU's Released between 2010 and 2020.
birds

Aircraft-Wildlife Collisions
age_at_mar

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

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

Sample of books on a shelf
cards

Deck of cards
avandia

Cardiovascular problems for two types of Diabetes medicines
diabetes2

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

Quadcopter Drone Blades
densityPlot

Density plot
antibiotics

Pre-existing conditions in 92 children
china

Child care hours
bac

Beer and blood alcohol content
children_gender_stereo

Gender Stereotypes in 5-7 year old Children
edaPlot

Exploratory data analysis plot
cars93

cars93
cherry

Summary information for 31 cherry trees
esi

Environmental Sustainability Index 2005
corr_match

Sample data sets for correlation problems
ball_bearing

Lifespan of ball bearings
bdims

Body measurements of 507 physically active individuals.
coast_starlight

Coast Starlight Amtrak train
buildAxis

Axis function substitute
burger

Burger preferences
births

North Carolina births, 100 cases
fastfood

Nutrition in fast food
gpa

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

College credits.
dotPlot

Dot plot
exclusive_relationship

Number of Exclusive Relationships
contTable

Generate Contingency Tables for LaTeX
dlsegments

Create a Double Line Segment Plot
cia_factbook

CIA Factbook Details on Countries
epa2021

Vehicle info from the EPA for 2021
boxPlot

Box plot
friday

Friday the 13th
flow_rates

River flow data
dotPlotStack

Add a Stacked Dot Plot to an Existing Plot
gss2010

2010 General Social Survey
classdata

Simulated class data
gender_discrimination

Bank manager recommendations based on gender
cle_sac

Cleveland and Sacramento
earthquakes

Earthquakes
epa2012

Vehicle info from the EPA for 2012
env_regulation

American Adults on Regulation and Renewable Energy
military

US Military Demographics
dream

Survey on views of the DREAM Act
ethanol

Ethanol Treatment for Tumors Experiment
normTail

Normal distribution tails
lsegments

Create a Line Segment Plot
climate70

Temperature Summary Data, Geography Limited
country_iso

Country ISO information
housing

Simulated data set on student housing
births14

US births
email

Data frame representing information about a collection of emails
full_body_scan

Poll about use of full-body airport scanners
drug_use

Drug use of students and parents
get_it_dunn_run

Get it Dunn Run, Race Times
daycare_fines

Daycare fines
evals

Professor evaluations and beauty
lizard_habitat

Field data on lizards observed in their natural habitat
duke_forest

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

Sample of 50 emails
immigration

Poll on illegal workers in the US
fact_opinion

Can Americans categorize facts and opinions?
family_college

Simulated sample of parent / teen college attendance
prison

Prison isolation experiment
president

United States Presidental History
fadeColor

Fade colors
heart_transplant

Heart Transplant Data
london_murders

London Murders, 2006-2011
gifted

Analytical skills of young gifted children
ebola_survey

Survey on Ebola quarantine
helium

Helium football
linResPlot

Create simple regression plot with residual plot
malaria

Malaria Vaccine Trial
orings

1986 Challenger disaster and O-rings
sat_improve

Simulated data for SAT score improvement
exams

Exam scores
nyc_marathon

New York City Marathon Times
goog

Google stock data
gsearch

Simulated Google search experiment
ipod

Length of songs on an iPod
gov_poll

Pew Research poll on government approval ratings
jury

Simulated juror data set
simulated_normal

Simulated data sets, drawn from a normal distribution.
infmortrate

Infant Mortality Rates, 2012
satgpa

SAT and GPA data
mcu_films

Marvel Cinematic Universe films
possum

Possums in Australia and New Guinea
kobe_basket

Kobe Bryant basketball performance
mariokart

Wii Mario Kart auctions from Ebay
male_heights

Sample of 100 male heights
murders

Data for 20 metropolitan areas
ipo

Facebook, Google, and LinkedIn IPO filings
gpa_study_hours

gpa_study_hours
cpr

CPR data set
mtl

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

lab_report
outliers

Simulated data sets for different types of outliers
piracy

Piracy and PIPA/SOPA
husbands_wives

Great Britain: husband and wife pairs
oscars

Oscar winners, 1929 to 2018
res_demo_1

Simulated data for regression
exam_grades

Exam and course grades for statistics students
elmhurst

Elmhurst College gift aid
pm25_2011_durham

Air quality for Durham, NC
poker

Poker winnings during 50 sessions
nycflights

Flights data
loop

Output a message while inside a loop
toohey

Simulated polling data set
mlb

Salary data for Major League Baseball (2010)
ucla_textbooks_f18

Sample of UCLA course textbooks for Fall 2018
photo_classify

Photo classifications: fashion or not
scale_color_openintro

Color scale constructor for OpenIntro IMS colors
ukdemo

United Kingdom Demographic Data
yawn

Contagiousness of yawning
simulated_dist

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

Financial information for 50 S&P 500 companies
scale_fill_openintro

Fill scale constructor for OpenIntro IMS colors
fish_oil_18

Findings on n-3 Fatty Acid Supplement Health Benefits
tourism

Turkey tourism
student_housing

Community college housing (simulated data, 2015)
socialexp

Social experiment
scotus_healthcare

Public Opinion with SCOTUS ruling on American Healthcare Act
student_sleep

Sleep for 110 students (simulated)
present

Birth counts
nuclear_survey

Nuclear Arms Reduction Survey
solar

Energy Output From Two Solar Arrays in San Francisco
xom

Exxon Mobile stock data
marathon

New York City Marathon Times (outdated)
mammogram

Experiment with Mammogram Randomized
opportunity_cost

Opportunity cost of purchases
hsb2

High School and Beyond survey
gpa_iq

Sample of students and their GPA and IQ
lmPlot

Linear regression plot with residual plot
fheights

Female college student heights, in inches
healthcare_law_survey

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

Daily observations for the S\&P 500
global_warming_pew

Pew survey on global warming
gradestv

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

Health Coverage and Health Status
openintro_colors

OpenIntro colors
playing_cards

Table of Playing Cards in 52-Card Deck
stats_scores

Final exam scores for twenty students
thanksgiving_spend

Thanksgiving spending, simulated based on Gallup poll.
openintro-package

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

Fake data for a gear company example
fcid

Summary of male heights from USDA Food Commodity Intake Database
mail_me

Influence of a Good Mood on Helpfulness
house

United States House of Representatives historical make-up
ppp_201503

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

Tip data
salinity

Salinity in Bimini Lagoon, Bahamas
smoking

UK Smoking Data
makeTube

Regression tube
london_boroughs

London Borough Boundaries
law_resume

Gender, Socioeconomic Class, and Interview Invites
openintro_cols

Function to extract OpenIntro IMS colors as hex codes
leg_mari

Legalization of Marijuana Support in 2010 California Survey
penelope

Guesses at the weight of Penelope (a cow)
sleep_deprivation

Survey on sleep deprivation and transportation workers
nba_heights

NBA Player heights from 2008-9
smallpox

Smallpox vaccine results
major_survey

Survey of Duke students and the area of their major
yrbss

Youth Risk Behavior Surveillance System (YRBSS)
helmet

Socioeconomic status and reduced-fee school lunches
myPDF

Custom PDF function
snowfall

Snowfall at Paradise, Mt. Rainier National Park
stem_cell

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

OpenIntro palettes
migraine

Migraines and acupuncture
openintro_pal

Return function to interpolate an OpenIntro IMS color palette
nba_players_19

NBA Players for the 2018-2019 season
lizard_run

Lizard speeds
russian_influence_on_us_election_2016

Russians' Opinions on US Election Influence in 2016
midterms_house

President's party performance and unemployment rate
penny_ages

Penny Ages
hfi

Human Freedom Index
histPlot

Histogram or hollow histogram
sex_discrimination

Bank manager recommendations based on sex
loans_full_schema

Loan data from Lending Club
race_justice

Yahoo! News Race and Justice poll results
penetrating_oil

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

North Carolina births, 1000 cases
res_demo_2

Simulated data for regression
winery_cars

Time Between Gondola Cars at Sterling Winery
ssd_speed

SSD read and write speeds
sulphinpyrazone

Treating heart attacks
stocks_18

Monthly Returns for a few stocks
resume

Which resume attributes drive job callbacks?
yrbss_samp

Sample of Youth Risk Behavior Surveillance System (YRBSS)
treeDiag

Construct tree diagrams
mammals

Sleep in Mammals
mlbbat10

Major League Baseball Player Hitting Statistics for 2010
sinusitis

Sinusitis and antibiotic experiment
male_heights_fcid

Random sample of adult male heights
seattlepets

Names of pets in Seattle
mlb_players_18

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

UCLA courses in Fall 2018
offshore_drilling

California poll on drilling off the California coast
simulated_scatter

Simulated data for sample scatterplots
supreme_court

Supreme Court approval rating
stent30

Stents for the treatment of stroke
starbucks

Starbucks nutrition
unemploy_pres

President's party performance and unemployment rate
unempl

Annual unemployment since 1890
write_pkg_data

Create a CSV variant of .rda files
pew_energy_2018

Pew Survey on Energy Sources in 2018
qqnormsim

Generate simulated QQ plots
speed_gender_height

Speed, gender, and height of 1325 students
rosling_responses

Sample Responses to Two Public Health Questions
prius_mpg

User reported fuel efficiency for 2017 Toyota Prius Prime
textbooks

Textbook data for UCLA Bookstore and Amazon
transplant

Transplant consultant success rate (fake data)
sp500_seq

S&P 500 stock data
toy_anova

Simulated data set for ANOVA
teacher

Teacher Salaries in St. Louis, Michigan