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::docment(), 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

6,018

Version

2.1.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Mine <c3><87>etinkaya-Rundel

Last Published

April 19th, 2021

Functions in openintro (2.1.0)

CCP

Plot a Cartesian Coordinate Plane
ChiSquareTail

Plot upper tail in chi-square distribution
BG

Add background color to a plot
Braces

Plot a Braces Symbol
AxisInDollars

Build Better Looking Axis Labels for US Dollars
AxisInPercent

Build Better Looking Axis Labels for Percentages
CT2DF

Contingency Table to Data Frame
IMSCOL

Introduction to Modern Statistics (IMS) Colors
COL

OpenIntro Statistics colors
ArrowLines

Create a Line That may have Arrows on the Ends
absenteeism

Absenteeism from school in New South Wales
babies

The Child Health and Development Studies
acs12

American Community Survey, 2012
association

Simulated data for association plots
age_at_mar

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

Cardiovascular problems for two types of Diabetes medicines
boxPlot

Box plot
assortive_mating

Eye color of couples
ami_occurrences

Acute Myocardial Infarction (Heart Attack) Events
arbuthnot

Male and female births in London
MosaicPlot

Custom Mosaic Plot
babies_crawl

Crawling age
dotPlot

Dot plot
bac

Beer and blood alcohol content
ball_bearing

Lifespan of ball bearings
cancer_in_dogs

Cancer in dogs
ask

How important is it to ask pointed questions?
cards

Deck of cards
cchousing

Community college housing (simulated data)
bdims

Body measurements of 507 physically active individuals.
cars93

cars93
ames

Housing prices in Ames, Iowa
cia_factbook

CIA Factbook Details on Countries
antibiotics

Pre-existing conditions in 92 children
births14

US births
PlotWLine

Plot data and add a regression line
births

North Carolina births, 100 cases
birds

Aircraft-Wildlife Collisions
elmhurst

Elmhurst College gift aid
burger

Burger preferences
contTable

Generate Contingency Tables for LaTeX
email

Data frame representing information about a collection of emails
children_gender_stereo

Gender Stereotypes in 5-7 year old Children
cpr

CPR data set
dotPlotStack

Add a Stacked Dot Plot to an Existing Plot
calc_streak

Calculate hit streaks
coast_starlight

Coast Starlight Amtrak train
cpu

CPU's Released between 2010 and 2020.
classdata

Simulated class data
drug_use

Drug use of students and parents
buildAxis

Axis function substitute
census

Random sample of 2000 U.S. Census Data
ebola_survey

Survey on Ebola quarantine
epa2012

Vehicle info from the EPA
climate70

Temperature Summary Data, Geography Limited
books

Sample of books on a shelf
cle_sac

Cleveland and Sacramento
edaPlot

Exploratory data analysis plot
full_body_scan

Poll about use of full-body airport scanners
earthquakes

Earthquakes
gear_company

Fake data for a gear company example
china

Child care hours
esi

Environmental Sustainability Index 2005
evals

Professor evaluations and beauty
ethanol

Ethanol Treatment for Tumors Experiment
global_warming_pew

Pew survey on global warming
gifted

Analytical skills of young gifted children
densityPlot

Density plot
drone_blades

Quadcopter Drone Blades
dream

Survey on views of the DREAM Act
cherry

Summary information for 31 cherry trees
health_coverage

Health Coverage and Health Status
credits

College credits.
fadeColor

Fade colors
fheights

Female college student heights, in inches
fastfood

Nutrition in fast food
fcid

Summary of male heights from USDA Food Commodity Intake Database
family_college

Simulated sample of parent / teen college attendance
dlsegments

Create a Double Line Segment Plot
diabetes2

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

Simulated Google search experiment
heart_transplant

Heart Transplant Data
country_iso

Country ISO information
gss2010

2010 General Social Survey
goog

Google stock data
corr_match

Sample data sets for correlation problems
email50

Sample of 50 emails
gov_poll

Pew Research poll on government approval ratings
helium

Helium football
env_regulation

American Adults on Regulation and Renewable Energy
exclusive_relationship

Number of Exclusive Relationships
husbands_wives

Great Britain: husband and wife pairs
gpa_study_hours

gpa_study_hours
gender_discrimination

Bank manager recommendations based on gender
fish_oil_18

Findings on n-3 Fatty Acid Supplement Health Benefits
histPlot

Histogram or hollow histogram
healthcare_law_survey

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

Can Americans categorize facts and opinions?
gradestv

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

Simulated juror data set
get_it_dunn_run

Get it Dunn Run, Race Times
house

United States House of Representatives historical make-up
law_resume

Gender, Socioeconomic Class, and Interview Invites
ipod

Length of songs on an iPod
leg_mari

Legalization of Marijuana Support in 2010 California Survey
immigration

Poll on illegal workers in the US
helmet

Socioeconomic status and reduced-fee school lunches
mcu_films

Marvel Cinematic Universe films
loans_full_schema

Loan data from Lending Club
mariokart

Wii Mario Kart auctions from Ebay
hfi

Human Freedom Index
london_boroughs

London Borough Boundaries
exam_grades

Exam and course grades for statistics students
flow_rates

River flow data
mammogram

Experiment with Mammogram Randomized
marathon

New York City Marathon Times
london_murders

London Murders, 2006-2011
loop

Output a message while inside a loop
linResPlot

Create simple regression plot with residual plot
exams

Exam scores
normTail

Normal distribution tails
nycflights

Flights data
ncbirths

North Carolina births, 1000 cases
nba_players_19

NBA Players for the 2018-2019 season
nba_heights

NBA Player heights from 2008-9
myPDF

Custom PDF function
friday

Friday the 13th
orings

1986 Challenger disaster and O-rings
pew_energy_2018

Pew Survey on Energy Sources in 2018
nuclear_survey

Nuclear Arms Reduction Survey
offshore_drilling

California poll on drilling off the California coast
gpa

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

Survey of Duke students and the area of their major
oscars

Oscar winners, 1929 to 2018
lmPlot

Linear regression plot with residual plot
pm25_2011_durham

Air quality for Durham, NC
simulated_scatter

Simulated data for sample scatterplots
russian_influence_on_us_election_2016

Russians' Opinions on US Election Influence in 2016
lab_report

lab_report
sinusitis

Sinusitis and antibiotic experiment
poker

Poker winnings during 50 sessions
salinity

Salinity.
kobe_basket

Kobe Bryant basketball performance
photo_classify

Photo classifications: fashion or not
male_heights_fcid

Random sample of adult male heights
military

US Military Demographics
mlb

Salary data for Major League Baseball (2010)
openintro-package

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

OpenIntro colors
penetrating_oil

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

Sleep in Mammals
present

Birth counts
president

United States Presidental History
penny_ages

Penny Ages
ssd_speed

SSD read and write speeds
makeTube

Regression tube
res_demo_1

Simulated data for regression
gpa_iq

Sample of students and their GPA and IQ
res_demo_2

Simulated data for regression
housing

Simulated data set on student housing
hsb2

High School and Beyond survey
mlb_players_18

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

President's party performance and unemployment rate
starbucks

Starbucks nutrition
infmortrate

Infant Mortality Rates, 2012
supreme_court

Supreme Court approval rating
resume

Which resume attributes drive job callbacks? (Race and gender under study.)
ppp_201503

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

Migraines and acupuncture
possum

possum
sulphinpyrazone

Treating heart attacks
rosling_responses

Sample Responses to Two Public Health Questions
toy_anova

Simulated data set for ANOVA
stats_scores

Final exam scores for twenty students
mlbbat10

Major League Baseball Player Hitting Statistics for 2010
mtl

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

Transplant consultant success rate (fake data)
qqnormsim

Generate simulated QQ plots
murders

Data for 20 metropolitan areas.
stem_cell

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

Teacher Salaries in St. Louis, Michigan
textbooks

Textbook data for UCLA Bookstore and Amazon
winery_cars

Time Between Gondola Cars at Sterling Winery
race_justice

Yahoo! News Race and Justice poll results
openintro_cols

Function to extract OpenIntro IMS colors as hex codes
simulated_dist

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

Simulated data sets, drawn from a normal distribution.
sp500_seq

S&P 500 stock data
write_pkg_data

Create a CSV variant of .rda files
ipo

Facebook, Google, and LinkedIn IPO filings
scale_color_openintro

Color scale constructor for OpenIntro IMS colors
openintro_pal

Return function to interpolate an OpenIntro IMS color palette
student_housing

Community college housing (simulated data, 2015)
speed_gender_height

Speed, gender, and height of 1325 students
scale_fill_openintro

Fill scale constructor for OpenIntro IMS colors
outliers

Simulated data sets for different types of outliers
smoking

UK Smoking Data
penelope

Guesses at the weight of Penelope (a cow)
snowfall

Snowfall at Paradise, Mt. Rainier National Park
tips

Tip data
scotus_healthcare

Public Opinion with SCOTUS ruling on American Healthcare Act
student_sleep

Sleep for 110 students (simulated)
seattlepets

Names of pets in Seattle
thanksgiving_spend

Thanksgiving spending, simulated based on Gallup poll.
socialexp

Social experiment
treeDiag

Construct tree diagrams
mail_me

Influence of a Good Mood on Helpfulness
malaria

Malaria Vaccine Trial
lsegments

Create a Line Segment Plot
ucla_f18

UCLA courses in Fall 2018
male_heights

Sample of 100 male heights
solar

Energy Output From Two Solar Arrays in San Francisco
openintro_palettes

OpenIntro palettes
ucla_textbooks_f18

Sample of UCLA course textbooks for Fall 2018
opportunity_cost

Opportunity cost of purchases
piracy

Piracy and PIPA/SOPA
stent30

Stents for the treatment of stroke
toohey

Simulated polling data set
stocks_18

Monthly Returns for a few stocks
tourism

Turkey tourism
playing_cards

Table of Playing Cards in 52-Card Deck
yawn

Contagiousness of yawning
xom

Exxon Mobile stock data
yrbss_samp

Sample of Youth Risk Behavior Surveillance System (YRBSS)
ukdemo

United Kingdom Demographic Data
yrbss

Youth Risk Behavior Surveillance System (YRBSS)
prison

Prison isolation experiment
prius_mpg

User reported fuel efficiency for 2017 Toyota Prius Prime
satgpa

SAT and GPA data
sat_improve

Simulated data for SAT score improvement
sleep_deprivation

Survey on sleep deprivation and transportation workers
sp500_1950_2018

Daily observations for the S\&P 500
sp500

Financial information for 50 S&P 500 companies
smallpox

Smallpox vaccine results
unempl

Annual unemployment since 1890
unemploy_pres

President's party performance and unemployment rate