Cran.ism.ac.jp

Package ‘openintro' February 20, 2015 Title OpenIntro data sets and supplemental functions Author David M Diez, Christopher D Barr, and Mine Cetinkaya-Rundel Maintainer David M Diez <david@openintro.org> Description This package is a supplement to OpenIntro Statistics, which is a free textbook available at openintro.org (at costpaperbacks are also available for under $10 on Amazon). Thepackage contains data sets used in the textbook along withcustom plotting functions for reproducing book figures. Notethat many functions and examples include color transparency.
Some plotting elements may not show up properly (or at all) insome Windows versions.
License GPL-2 GPL-3 Depends graphics, grDevices, stats, utils, R (>= 2.10) Date/Publication 2012-09-01 12:59:27 NeedsCompilation no R topics documented: R topics documented: OpenIntro data sets and supplemental functions This package is a supplement to OpenIntro Statistics, which is a free textbook available at (at-cost paperbacks are also available for under $10 on Amazon). The package containsdata sets used in the textbook along with custom plotting functions for reproducing book figures.
Note that many functions and examples include color transparency. Some plotting elements maynot show up properly (or at all) in some Windows versions.
Some colors include transparency, which means they will not be plotted in some operating systems(e.g. Windows). However, the plots may be viewed if they are written to a PDF or PNG file first.
For a discussion of this topic, please seeTwo new functions, and were created in this package and may also be used to set upnice plotting files that allow for transparency.
David M Diez, Christopher D Barr, Mine Cetinkaya-Rundel Maintainer: DM Diez <david.m.diez@gmail.com> #===> boxPlot <===# #===> histPlot, example 1 <===# histPlot(run10$time[run10$gender=='M'], probability=TRUE, xlim=c(30, 180), ylim=c(0, 0.025), hollow=TRUE) hollow=TRUE, lty=3, border='red') legend('topleft', col=c('black', 'red'), lty=2:3, legend=c('M','F')) histPlot(run10$time, col=fadeColor('yellow', '33'), border='darkblue', probability=TRUE, breaks=30, lwd=3) brks <- c(40, 50, 60, 65, 70, 75, 80, seq(82.5, 120, 2.5), 125, 130, 135, 140, 150, 160, 180) #===> histPlot, example 2 <===# add=TRUE, border='red', lty=3) add=TRUE, border='blue', lty=4) legend('topright', lty=2:4, col=c('black', 'red', 'blue'), legend=c('small', 'midsize', 'large')) #===> densityPlot <===# legend('topright', col=c('black','red'), lty=1:2, #===> identifying reasons for outliers <===# these <- which(marioKart$totalPr > 80) # see the data collection criteria for # why these observations do not belong.
lines(rep(marioKart$totalPr[these[1]], 2), c(2.4, 2)) lines(rep(marioKart$totalPr[these[2]], 2), c(1.6, 2)) #===> compare plotting methods <===# histPlot(cars$price, ylim=c(0, 0.1), axes=FALSE, ylab='', boxPlot(cars$price, width=0.03, horiz=TRUE, add=0.067, axes=FALSE) dotPlot(cars$price, at=0.095, add=TRUE) #===> controlling the number of axis labels <===# specify the number of labels x <- textbooks$diff histPlot(x, axes=FALSE) buildAxis(1, x, n=4, nMin=4, nMax=4) histPlot(x, axes=FALSE) buildAxis(1, x, n=5, nMin=5, nMax=5) histPlot(x, axes=FALSE) # no decent axis is found for this data with exactly six labels # no min or max specified, only a target number of labels: buildAxis(1, x, n=6) #===> creating normal plots with tails <===# par(mfrow=c(2,3), mar=c(3,3,1,1), mgp=c(1.7, 0.7, 0)) normTail(U=1, xLab='symbol', cex.axis=0.7) normTail(5, 13, L=-5, M=c(0,3), U=12, xAxisIncr=2) normTail(102, 4, xlim=c(97,110), M=c(100,103)) normTail(-10.0, 5.192, M=c(-5,2), digits=1, xAxisIncr=2) #===> Exploratory Data Analysis Plot <===# Convert state names to abbreviations and back again Two utility functions. One converts state names to the state abbreviations, and the second does theopposite.
A vector of state name, where there is a little fuzzy matching.
A vector of state abbreviation.
Returns a vector of the same length with the corresponding state names or abbreviations.
# _ Some Spelling/Capitalization Errors Okay _# Age at first marriage of 5,534 US women.
Age at first marriage of 5,534 US women who responded to the National Survey of Family Growth(NSFG) conducted by the CDC in the 2006 and 2010 cycle.
A data frame with 5,534 observations and 1 variable.
age Age a first marriage.
National Survey of Family Growth, 2006-2010 cycle, Lifespan of ball bearings A simulated data set on lifespan of ball bearings.
A data frame with 75 observations on the following variable.
lifeSpan Lifespan of ball bearings (in hours).
Simulated data.
Body measurements of 507 physically active individuals.
Body girth measurements and skeletal diameter measurements, as well as age, weight, height andgender, are given for 507 physically active individuals - 247 men and 260 women. These data canbe used to provide statistics students practice in the art of data analysis. Such analyses range fromsimple descriptive displays to more complicated multivariate analyses such as multiple regressionand discriminant analysis.
A data frame with 507 observations on the following 25 variables.
bia.di A numerical vector, respondent's biacromial diameter in centimeters.
bii.di A numerical vector, respondent's biiliac diameter (pelvic breadth) in centimeters.
bit.di A numerical vector, respondent's bitrochanteric diameter in centimeters.
che.de A numerical vector, respondent's chest depth in centimeters, measured between spine and sternum at nipple level, mid-expiration.
che.di A numerical vector, respondent's chest diameter in centimeters, measured at nipple level, elb.di A numerical vector, respondent's elbow diameter in centimeters, measured as sum of two wri.di A numerical vector, respondent's wrist diameter in centimeters, measured as sum of two kne.di A numerical vector, respondent's knee diameter in centimeters, measured as sum of two ank.di A numerical vector, respondent's ankle diameter in centimeters, measured as sum of two sho.gi A numerical vector, respondent's shoulder girth in centimeters, measured over deltoid mus- che.gi A numerical vector, respondent's chest girth in centimeters, measured at nipple line in males and just above breast tissue in females, mid-expiration.
wai.gi A numerical vector, respondent's waist girth in centimeters, measured at the narrowest part of torso below the rib cage as average of contracted and relaxed position.
nav.gi A numerical vector, respondent's navel (abdominal) girth in centimeters, measured at um- bilicus and iliac crest using iliac crest as a landmark.
hip.gi A numerical vector, respondent's hip girth in centimeters, measured at at level of bi- thi.gi A numerical vector, respondent's thigh girth in centimeters, measured below gluteal fold as the average of right and left girths.
bic.gi A numerical vector, respondent's bicep girth in centimeters, measured when flexed as the average of right and left girths.
for.gi A numerical vector, respondent's forearm girth in centimeters, measured when extended, palm up as the average of right and left girths.
kne.gi A numerical vector, respondent's knee diameter in centimeters, measured as sum of two cal.gi A numerical vector, respondent's calf maximum girth in centimeters, measured as average of right and left girths.
ank.gi A numerical vector, respondent's ankle minimum girth in centimeters, measured as average of right and left girths.
wri.gi A numerical vector, respondent's wrist minimum girth in centimeters, measured as average of right and left girths.
age A numerical vector, respondent's age in years.
wgt A numerical vector, respondent's weight in kilograms.
hgt A numerical vector, respondent's height in centimeters.
sex A categorical vector, 1 if the respondent is male, 0 if female.
Heinz G, Peterson LJ, Johnson RW, Kerk CJ. 2003. Exploring Relationships in Body Dimensions.
Journal of Statistics Education 11(2).
North Carolina births Data on a random sample of 100 births for babies in North Carolina where the mother was not asmoker and another 50 where the mother was a smoker.
A data frame with 150 observations on the following 14 variables.
fAge Father's age.
mAge Mother's age.
weeks Weeks at which the mother gave birth.
premature Indicates whether the baby was premature or not.
visits Number of hospital visits.
gained Weight gained by mother.
weight Birth weight of the baby.
sexBaby Gender of the baby.
smoke Whether or not the mother was a smoker.
These birth records were Birth records released by North Carolina in 2004.
An alternative to boxplot. Equations are not accepted. Instead, the second argument, fact, is usedto split the data.
boxPlot(x, fact=NULL, horiz=FALSE, width=2/3, lwd=1, lcol='black', medianLwd=2, pch=20, pchCex=1.8, col=rgb(0,0,0,0.25), add=FALSE, key=NULL, axes=TRUE, xlab='', ylab='', xlim=NULL, ylim=NULL, A numerical vector.
A character or factor vector defining the grouping for side-by-side box plots.
If TRUE, the box plot is oriented horizontally.
The width of the boxes in the plot. Value between 0 and 1.
Width of lines used in box and whiskers.
Color of the box, median, and whiskers.
Width of the line marking the median.
Plotting character of outliers.
Size of outlier character.
Color of outliers.
If FALSE, a new plot is created. Otherwise, the boxplots are added to the currentplot for values of TRUE or a numerical vector specifying the locations of theboxes.
The order in which to display the side-by-side boxplots. If locations are specifiedin add, then the elements of add will correspond to the elements of key.
Whether to plot the axes.
Label for the x axis.
Label for the y axis.
Limits for the x axis.
Limits for the y axis.
Indicate whether NA values should be removed.
Additional arguments to plot.
#===> comparison 1 <===# #===> comparison 2 <===# boxPlot(run10$time, run10$gender, col=fadeColor('black', '22')) #===> modifications using boxPlot <===# boxPlot(run10$time, run10$gender, xlab='gender', ylab='run time (min)', plot(0,0, xlab='gender', ylab='run time (min)', xlim=c(0,6), ylim=c(30, 180), axes=FALSE) boxPlot(run10$time, run10$gender, width=0.5, lwd=2, lcol=4, medianLwd=4, pch=1, pchCex=1, col=4, plot(0,0, ylab='gender', xlab='run time (min)', xlim=c(30, 180), ylim=c(0, 3), axes=FALSE) boxPlot(run10$time, run10$gender, horiz=TRUE, xlab='run time (min)', ylab='gender', add=1:2, key=c('F','M')) # 'key' can be used to restrict to only the #===> combine boxPlot and dotPlot <===# boxPlot(tips$tip, tips$day, horiz=TRUE, key=c('Tuesday', 'Friday')) dotPlot(tips$tip, tips$day, add=TRUE, at=1:2+0.05, #===> adding a box <===# axis(1, at=1:2, labels=c('M', 'F')) boxPlot(run10$time[run10$gender=='F'], add=2, horiz=TRUE, axes=FALSE) axis(2, at=1:2, labels=c('M', 'F')) Axis function substitute The function buildAxis is built to provide more control of the number of labels on the axis. Thisfunction is still under development.
buildAxis(side, limits, n, nMin = 2, nMax = 10, extend = 2, The side of the plot where to add the axis.
Either lower and upper limits on the axis or a data set.
The preferred number of axis labels.
The minimum number of axis labels.
The maximum number of axis labels.
How far the axis may extend beyond range(limits).
The smallest increment allowed.
Arguments passed to axis The primary reason behind building this function was to allow a plot to be created with similarfeatures but with different data sets. For instance, if a set of code was written for one data set andthe function axis had been utilized with pre-specified values, the axis may not match the plot of anew set of data. The function buildAxis addresses this problem by allowing the number of axislabels to be specified and controlled.
The axis is built by assigning penalties to a variety of potential axis setups, ranking them based onthese penalties and then selecting the axis with the best score.
A vector of the axis plotted.
#===> 0 <===# limits <- rnorm(100, 605490, 10) hist(limits, axes=FALSE) buildAxis(1, limits, 2, nMax=4) #===> 1 <===# x <- seq(0, 500, 10) y <- 8*x+rnorm(length(x), mean=6000, sd=200) plot(x, y, axes=FALSE) buildAxis(1, limits=x, n=5) buildAxis(2, limits=y, n=3) #===> 2 <===# x <- 9528412 + seq(0, 200, 10) y <- 8*x+rnorm(length(x), mean=6000, sd=200) plot(x, y, axes=FALSE) temp <- buildAxis(1, limits=x, n=4) buildAxis(2, y, 3) #===> 3 <===# x <- seq(367, 1251, 10) y <- 7.5*x+rnorm(length(x), mean=6000, sd=800) plot(x, y, axes=FALSE) buildAxis(1, limits=x, n=4, nMin=3, nMax=3) buildAxis(2, limits=y, n=4, nMin=3, nMax=5) #===> 4 <===# x <- seq(367, 367.1, 0.001) y <- 7.5*x+rnorm(length(x), mean=6000, sd=0.01) plot(x, y, axes=FALSE) buildAxis(1, limits=x, n=4, nMin=5, nMax=6) buildAxis(2, limits=y, n=2, nMin=3, nMax=4) #===> 5 <===# x <- seq(-0.05, -0.003, 0.0001) y <- 50 + 20*x + rnorm(length(x), sd=0.1) plot(x, y, axes=FALSE) buildAxis(1, limits=x, n=4, nMin=5, nMax=6) buildAxis(2, limits=y, n=4, nMax=5) #===> 6 <===# x <- seq(-0.0097, -0.008, 0.0001) y <- 50 + 20*x + rnorm(length(x), sd=0.1) plot(x, y, axes=FALSE) buildAxis(1, limits=x, n=4, nMin=2, nMax=5) buildAxis(2, limits=y, n=4, nMax=5) #===> 7 <===# x <- seq(0.03, -0.003099, -0.00001) y <- 50 + 20*x + rnorm(length(x), sd=0.1) plot(x, y, axes=FALSE) buildAxis(1, limits=x, n=4, nMin=2, nMax=5) buildAxis(2, limits=y, n=4, nMax=6) #===> 8 - repeat <===# m <- runif(1)/runif(1) + rgamma(1, runif(1)/runif(1), runif(1)/runif(1)) s <- rgamma(1, runif(1)/runif(1), runif(1)/runif(1)) x <- rnorm(50, m, s) hist(x, axes=FALSE) buildAxis(1, limits=x, n=5, nMin=4, nMax=6, eps=10 -12) if(diff(range(x)) < 10 -12){ cat("too small n") A data frame with 54 rows and 6 columns. The columns represent the variables type, price, mpgCity, driveTrain, passengers, weight for a sample of 54 cars from 1993. This data is asubset of the Cars93 data set from the MASS package.
A data frame with 54 observations on the following 6 variables.
type The vehicle type with levels large, midsize, and small.
price Vehicle price (USD).
mpgCity Vehicle mileage in city (miles per gallon).
driveTrain Vehicle drive train with levels 4WD, front, and rear.
passengers The vehicle passenger capacity.
weight Vehicle weight (lbs).
These cars represent a random sample for 1993 models that were in both Consumer Reports andPACE Buying Guide. Only vehicles of type 'small', 'midsize', and 'large' were include.
Further description can be found in Lock (1993). Use the URL Lock, R. H. (1993) 1993 New Car Data. Journal of Statistics Education 1(1).
#===> vehicle price by type <===# hollow=TRUE, add=TRUE, border='red', lty=3) hollow=TRUE, add=TRUE, border='blue', lty=4) legend('topright', lty=2:4, col=c('black', 'red', 'blue'), legend=c('small', 'midsize', 'large')) #===> vehicle price versus weight <===# plot(cars$weight, cars$price, col=fadeColor('magenta', '88'), #===> mileage versus weight <===# plot(cars$weight, cars$mpgCity, type="n") temp <- c(seq(1000, 5000, 100), rev(seq(1000, 5000, 100)), 1000) hold <- 87.11 - 0.03508*temp + 0.000004432*temp 2 + 7*c(rep(-1, 41), rep(1, 41), 1) polygon(temp, hold, col="#E2E2E2", col='chocolate4', pch=20, cex=2) Community college housing (simulated data) These are simulated data and intended to represent housing prices of students at a community col-lege.
A data frame with 75 observations on the following variable.
price Monthly housing price, simulated.
OpenIntro Statistics, Random sample of 2000 U.S. Census Data A random sample of 500 observations from the 2000 U.S. Census Data.
A data frame with 500 observations on the following 8 variables.
censusYear Census Year.
stateFIPScode Name of state.
totalFamilyIncome Total family income (in U.S. dollars).
age Age.
sex Sex with levels Female and Male.
raceGeneral Race with levels American Indian or Alaska Native, Black, Chinese, Japanese, Other Asian or Pacific Islander, Two major races, White and Other.
maritalStatus Marital status with levels Divorced, Married/spouse absent, Married/spouse present, Never married/single, Separated and Widowed.
totalPersonalIncome Total personal income (in U.S. dollars).
these <- census[,3] > 0 # income greater than 0 Simulated class data This data is simulated and is meant to represent students scores from three different lectures whowere all given the same exam.
A data frame with 164 observations on the following 2 variables.
m1 Represents a first midterm score.
lecture Three classes: a, b, and c.
OpenIntro Statistics, Chapter 8.
anova(lm(m1 lecture, classData)) OpenIntro Statistics colors These are the core colors used for the OpenIntro Statistics textbook. The blue, green, yellow, andred colors are also gray-scaled, meaning no changes are required when printing black and whitecopies.
A 7-by-4 matrix of 7 colors with four fading scales: blue, green, yellow, red, black, gray, and lightgray.
Colors selected by OpenIntro's in-house graphic designer, OpenIntro Statistics, Second Edition, plot(1:7, 7:1, col=COL, pch=19, cex=6, xlab="", ylab="", xlim=c(0.5,7.5), ylim=c(-2.5,8), axes=FALSE) text(1:7, 7:1+0.7, paste("COL[", 1:7, "]", sep=""), cex=0.9) points(1:7, 7:1-0.7, col=COL[,2], pch=19, cex=6) points(1:7, 7:1-1.4, col=COL[,3], pch=19, cex=6) points(1:7, 7:1-2.1, col=COL[,4], pch=19, cex=6) Generate Contingency Tables for LaTeX Input a data frame or a table, and the LaTeX output will be returned. Options exist for row andcolumn proportions as well as for showing work.
contTable(x, prop = c("none", "row", "col"), show = FALSE, digits = 3) A data frame (with two columns) or a table.
Indicate whether row ("r", "R", "row") or column ("c", "C", "col") propor-tions should be used. The default is to simply print the contingency table.
If row or column proportions are specified, indicate whether work should beshown.
The number of digits after the decimal that should be shown for row or columnproportions.
The contTable function makes substantial use of the function.
OpenIntro Statistics, United States Counties Data for 3143 counties in the United States. See the data set for additional vari-ables.
A data frame with 3143 observations on the following 15 variables.
name County names.
state State names.
pop2000 Population in 2000.
pop2010 Population in 2010.
fed_spend Federal spending per capitapoverty Percent of population in poverty.
homeownership Homeownership rate, 2006-2010.
multiunit Percent of housing units in multi-unit structures, 2006-2010.
income Income per capita income.
med_income Median income.
These data were collected from and its accom-panying pages.
OpenIntro Statistics, p00 <- county$pop2000 p10 <- county$pop2010 hist((p10 - p00)/p00) United States Counties Data for 3143 counties in the United States.
A data frame with 3143 observations on the following 53 variables.
state State.
name County name.
FIPS FIPS code.
pop2010 2010 county population.
pop2000 2000 county population.
age_under_5 Percent of population under 5 (2010).
age_under_18 Percent of population under 18 (2010).
age_over_65 Percent of population over 65 (2010).
female Percent of population that is female (2010).
white Percent of population that is white (2010).
black Percent of population that is black (2010).
native Percent of population that is a Native American (2010).
asian Percent of population that is a Asian (2010).
pac_isl Percent of population that is Hawaii or Pacific Islander (2010).
two_plus_races Percent of population that identifies as two or more races (2010).
hispanic Percent of population that is Hispanic (2010).
white_not_hispanic Percent of population that is white and not Hispanic (2010).
no_move_in_one_plus_year Percent of population that has not moved in at least one year (2006- foreign_born Percent of population that is foreign-born (2006-2010).
foreign_spoken_at_home Percent of population that speaks a foreign language at home (2006- hs_grad Percent of population that is a high school graduate (2006-2010).
bachelors Percent of population that earned a bachelor's degree (2006-2010).
veterans Percent of population that are veterans (2006-2010).
mean_work_travel Mean travel time to work (2006-2010).
housing_units Number of housing units (2010).
home_ownership Homeownership rate (2006-2010).
housing_multi_unit Housing units in multi-unit structures (2006-2010).
median_val_owner_occupied Median value of owner-occupied housing units (2006-2010).
households Households (2006-2010).
persons_per_household Persons per household (2006-2010).
per_capita_income Per capita money income in past 12 months (2010 dollars, 2006-2010)median_household_income Median household income (2006-2010).
poverty Percent below poverty level (2006-2010).
private_nonfarm_establishments Private nonfarm establishments (2009).
private_nonfarm_employment Private nonfarm employment (2009).
percent_change_private_nonfarm_employment Private nonfarm employment, percent change from 2000 to 2009.
nonemployment_establishments Nonemployer establishments (2009).
firms Total number of firms (2007).
black_owned_firms Black-owned firms, percent (2007).
native_owned_firms Native American-owned firms, percent (2007).
asian_owned_firms Asian-owned firms, percent (2007).
pac_isl_owned_firms Native Hawaiian and other Pacific Islander-owned firms, percent (2007).
hispanic_owned_firms Hispanic-owned firms, percent (2007).
women_owned_firms Women-owned firms, percent (2007).
manufacturer_shipments_2007 Manufacturer shipments, 2007 ($1000).
mercent_whole_sales_2007 Merchange wholesaler sales, 2007 ($1000).
sales Retail sales, 2007 ($1000).
sales_per_capita Retail sales per capita, 2007.
accommodation_food_service Accommodation and food services sales, 2007 ($1000).
building_permits Building permits (2010).
fed_spending Federal spending (2009).
area Land area in square miles (2010).
density Persons per square mile (2010).
OpenIntro Statistics, College credits.
A simulated data set of number of credits taken by college students each semester.
A data frame with 100 observations on the following variable.
credits Number of credits.
Simulated data.
Compute kernel density plots, written in the same structure as Histograms can be auto-matically added for teaching purposes.
densityPlot(x, fact = NULL, bw = "nrd0", histo = c("none", "faded", "hollow"), breaks = "Sturges", fading = "0E", fadingBorder = "25", lty = NULL, lwd = 1, col = c("black", "red", "blue"), key = NULL, add = FALSE, adjust = 1, kernel = c("gaussian", "epanechnikov", "rectangular", weights = NULL, n = 512, from, to, na.rm = FALSE, xlim = NULL, ylim = NULL, main = "", .) A numerical vector.
A character or factor vector defining the grouping for data in x.
Bandwidth. See density.
Whether to plot a faded histogram ('faded') or hollow histogram ('hollow')in the background. By default, no histogram will be plotted.
The breaks argument for histPlot if histo is 'faded' or 'hollow'.
Character value of hexadecimal, e.g. '22' or '5D', describing the amount offading inside the rectangles of the histogram if histo='faded'.
Character value of hexadecimal, e.g. '22' or '5D', describing the amountof fading of the rectangle borders of the histogram if histo is 'faded' or Numerical vector describing the line type for the density curve(s). Each elementcorresponds to a different level of the argumentfact.
Numerical vector describing the line width for the density curve(s). Each ele-ment corresponds to a different level of the argumentfact.
Numerical vector describing the line color for the density curve(s). Each elementcorresponds to a different level of the argumentfact.
An argument to specify ordering of the factor levels.
If TRUE, the density curve is added to the plot.
Argument passed to density to adjust the bandwidth.
Argument passed to density to select the kernel used.
Argument passed to density to weight observations.
Argument passed to density to specify the detail in the density estimate.
Argument passed to density specifying the lowest value to include in the den-sity estimate.
Argument passed to density specifying the largest value to include in the den-sity estimate.
Argument passed to density specifying handling of NA values.
x-axis limits.
y-axis limits.
Title for the plot.
If add=FALSE, then additional arguments to plot.
histPlot(tips$tip[tips$day == 'Tuesday'], hollow=TRUE, xlim=c(0, 30), lty=1, main='Tips by day') histPlot(tips$tip[tips$day == 'Friday'], hollow=TRUE, border='red', add=TRUE, main='Tips by day') legend('topright', col=c('black', 'red'), lty=1:2, densityPlot(tips$tip, tips$day, col=c('black', 'red'), main='Tips by day') legend('topright', col=c('black', 'red'), lty=1:2, densityPlot(run10$time, histo='faded', breaks=15, main='Run time') densityPlot(run10$time, histo='hollow', breaks=30, fadingBorder='66', lty=1, main='Run time') Plot observations as dots.
dotPlot(x, fact = NULL, vertical = FALSE, at = 1, key = NULL, pch = 20, col = fadeColor("black", "66"), cex = 1.5, add = FALSE, axes = TRUE, xlim = NULL, ylim = NULL, .) A numerical vector.
A character or factor vector defining the grouping for data in x.
If TRUE, the plot will be oriented vertically.
The vertical coordinate of the points, or the horizontal coordinate if vertical=TRUE.
If fact is provided, then locations can be specified for each group.
The factor levels corresponding to at, pch, col, and cex.
Plotting character. If fact is given, then different plotting characters can bespecified for each factor level. If key is specified, the elements of pch willcorrespond to the elements of key.
Plotting character color. If fact is given, then different colors can be specifiedfor each factor level. If key is specified, the elements of col will correspond tothe elements of key.
Plotting character size. If fact is given, then different character sizes can bespecified for each factor level. If key is specified, the elements of cex willcorrespond to the elements of key.
If TRUE, then the points are added to the plot.
If FALSE, no axes are plotted.
Limits for the x axis.
Limits for the y axis.
Additional arguments to be passed to plot if add=FALSE or points if add=TRUE.
#===> example 1 <===# dotPlot(cars$price, cars$type, key=c('large', 'midsize', 'small'), cex=1:3) #===> example 2 <===# these <- run10$gender=='M' # disorganized levels in the above plot, which we could # organize with key. an example of organizing the levels.
key=c('20-24', '25-29', '30-34', '35-39')) par(las=0, mfrow=c(1,1)) #===> example 3 <===# xlim=c(25, 80), cex=1) # miss the outliers key=c('new', 'used'), horiz=TRUE, axes=FALSE) Exploratory data analysis plot Explore different plotting methods using a click interface.
edaPlot(dataFrame, Col=c('#888888', '#FF0000', '#222222', '#FFFFFF', '#CCCCCC', '#3377AA')) A data frame.
A vector containing six colors. The colors may be given in any form.
Below is a screen-capture image of the interface for edaPlot using the second data set in theexamples below. Red is used to highlight the two active variables and plotting type.
bat <- mlbBat10[mlbBat10$AB > 200,] mk <- marioKart[marioKart$totalPr < 100,] Data frame representing information about a collection of emails These data represent incoming emails for the first three months of 2012 for an email account (seeSource).
A email (email_sent) data frame has 3921 (1252) observations on the following 21 variables.
spam Indicator for whether the email was spam.
to_multiple Indicator for whether the email was addressed to more than one recipient.
from Whether the message was listed as from anyone (this is usually set by default for regular outgoing email).
cc Indicator for whether anyone was CCed.
sent_email Indicator for whether the sender had been sent an email in the last 30 days.
time Time at which email was sent.
image The number of images attached.
attach The number of attached files.
dollar The number of times a dollar sign or the word "dollar" appeared in the email.
winner Indicates whether "winner" appeared in the email.
inherit The number of times "inherit" (or an extension, such as "inheritance") appeared in the viagra The number of times "viagra" appeared in the email.
password The number of times "password" appeared in the email.
num_char The number of characters in the email, in thousands.
line_breaks The number of line breaks in the email (does not count text wrapping).
format Indicates whether the email was written using HTML (e.g. may have included bolding or active links).
re_subj Whether the subject started with "Re:", "RE:", "re:", or "rE:"exclaim_subj Whether there was an exclamation point in the subject.
urgent_subj Whether the word "urgent" was in the email subject.
exclaim_mess The number of exclamation points in the email message.
number Factor variable saying whether there was no number, a small number (under 1 million), or a big number.
David Diez's Gmail Account, early months of 2012. All personally identifiable information hasbeen removed.
OpenIntro Statistics, # Variables For Logistic Regression # # Variables are modified to match OpenIntro Statistics, Second Edition # As Is (7): spam, to_multiple, winner, format, re_subj, exclaim_subj # Omitted (6): from, sent_email, time, image, viagra, urgent_subj, number # Become Indicators (5): cc, attach, dollar, inherit, password <- ifelse(email$cc > 0, 1, 0) <- ifelse(email$attach > 0, 1, 0) <- ifelse(email$dollar > 0, 1, 0) e$inherit <- ifelse(email$inherit > 0, 1, 0) e$password <- ifelse(email$password > 0, 1, 0) # Transform (3): num_char, line_breaks, exclaim_mess <- cut(email$num_char, c(0,1,5,10,20,1000)) #e$line_breaks <- cut(email$line_breaks, c(0,10,100,500,10000)) #e$exclaim_mess <- cut(email$exclaim_mess, c(-1,0,1,5,10000)) g <- glm(spam to_multiple + winner + format + re_subj + exclaim_subj + cc + attach + dollar + inherit + password, # + #num_char + line_breaks + exclaim_mess, data=e, family=binomial) # Variable Selection Via AIC # # Splitting num_char by html # <- range(x) + c(-1, 1) wt <- sum(email$format)/nrow(email) <- density(x, bw=0.4, from=R[1], to=R[2]) <- density(x[email$format != 1], bw=0.4, from=R[1], to=R[2]) <- density(x[email$format == 1], bw=0.4, from=R[1], to=R[2]) htmlNo$y <- htmlNo$y #* (1-wt) htmlYes$y <- htmlYes$y #* wt + htmlNo$y plot(htmlAll, xlim=c(-4, 6), ylim=c(0, 0.4)) lines(htmlNo, col=4) lines(htmlYes, lwd=2, col=2) Sample of 50 emails This is a subsample of the data set.
A data frame with 50 observations on the following 21 variables.
spam Indicator for whether the email was spam.
to_multiple Indicator for whether the email was addressed to more than one recipient.
from Whether the message was listed as from anyone (this is usually set by default for regular outgoing email).
cc Indicator for whether anyone was CCed.
sent_email Indicator for whether the sender had been sent an email in the last 30 days.
time Time at which email was sent.
image The number of images attached.
attach The number of attached files.
dollar The number of times a dollar sign or the word "dollar" appeared in the email.
winner Indicates whether "winner" appeared in the email.
inherit The number of times "inherit" (or an extension, such as "inheritance") appeared in the viagra The number of times "viagra" appeared in the email.
password The number of times "password" appeared in the email.
num_char The number of characters in the email, in thousands.
line_breaks The number of line breaks in the email (does not count text wrapping).
format Indicates whether the email was written using HTML (e.g. may have included bolding or active links).
re_subj Whether the subject started with "Re:", "RE:", "re:", or "rE:"exclaim_subj Whether there was an exclamation point in the subject.
urgent_subj Whether the word "urgent" was in the email subject.
exclaim_mess The number of exclamation points in the email message.
number Factor variable saying whether there was no number, a small number (under 1 million), or a big number.
David Diez's Gmail Account, early months of 2012. All personally identifiable information hasbeen removed.
OpenIntro Statistics, d <- email[sample(nrow(email), 50),][c(1:25,27:50,26),] identical(d, email50) # the "[c(1,26,2:25,27:50),]" was added to reorder the cases Fade colors so they are transparent.
fadeColor(col, fade = "FF") An integer, color name, or RGB hexadecimal.
The amount to fade col. This value should be a character in hexadecimal from'00' to 'FF'. The smaller the value, the greater the fading.
new <- marioKart$cond == 'new' used <- marioKart$cond == 'used' #===> color numbers <===# dotPlot(marioKart$totalPr[new], ylim=c(0,3), xlim=c(25, 80), pch=20, col=2, cex=2, main='using regular colors') dotPlot(marioKart$totalPr[used], at=2, add=TRUE, col=4, pch=20, cex=2) dotPlot(marioKart$totalPr[new], ylim=c(0,3), xlim=c(25, 80), col=fadeColor(2, '22'), pch=20, cex=2, main='fading the colors first') dotPlot(marioKart$totalPr[used], at=2, add=TRUE, col=fadeColor(4, '22'), pch=20, cex=2) #===> color names <===# dotPlot(marioKart$totalPr[new], ylim=c(0,3), xlim=c(25, 80), pch=20, col='red', cex=2, main='using regular colors') dotPlot(marioKart$totalPr[used], at=2, add=TRUE, col='blue', pch=20, cex=2) dotPlot(marioKart$totalPr[new], ylim=c(0,3), xlim=c(25, 80), col=fadeColor('red', '22'), pch=20, cex=2, main='fading the colors first') dotPlot(marioKart$totalPr[used], at=2, add=TRUE, col=fadeColor('blue', '22'), pch=20, cex=2) #===> hexadecimal <===# dotPlot(marioKart$totalPr[new], ylim=c(0,3), xlim=c(25, 80), pch=20, col='#FF0000', cex=2, main='using regular colors') dotPlot(marioKart$totalPr[used], at=2, add=TRUE, col='#0000FF', pch=20, dotPlot(marioKart$totalPr[new], ylim=c(0,3), xlim=c(25, 80), col=fadeColor('#FF0000', '22'), pch=20, cex=2, main='fading the colors first') dotPlot(marioKart$totalPr[used], at=2, add=TRUE, col=fadeColor('#0000FF', '22'), pch=20, cex=2) #===> alternative: rgb function <===# dotPlot(marioKart$totalPr[new], ylim=c(0,3), xlim=c(25, 80), pch=20, col=rgb(1,0,0), cex=2, main='using regular colors') dotPlot(marioKart$totalPr[used], at=2, add=TRUE, col=rgb(0,0,1), dotPlot(marioKart$totalPr[new], ylim=c(0,3), xlim=c(25, 80), col=rgb(1,0,0,1/8), pch=20, cex=2, main='fading the colors first') dotPlot(marioKart$totalPr[used], at=2, add=TRUE, col=rgb(0,0,1,1/8), pch=20, cex=2) This data set addresses issues of how superstitions regarding Friday the 13th affect human behav-ior, and whether Friday the 13th is an unlucky day. Scanlon, et al. collected data on traffic andshopping patterns and accident frequency for Fridays the 6th and 13th between October of 1989and November of 1992.
There are three types of observations: traffic, shopping, and accident. For traffic, the researchersobtained information from the British Department of Transport regarding the traffic flows betweenjunctions 7 to 8 and junctions 9 to 10 of the M25 motorway. For shopping, they collected the num-bers of shoppers in nine different supermarkets in southeast England. For accidents, they collectednumbers of emergency admissions to hospitals due to transport accidents.
A data frame with 61 observations and 6 variables.
type Type of observation, traffic, shopping, or accident.
date Year and month of observation.
sixth Counts on the 6th of the month.
thirteenth Counts on the 13th of the month.
diff Difference between the sixth and the thirteenth.
location Location where data is collected.
Scanlon, T.J., Luben, R.N., Scanlon, F.L., Singleton, N. (1993), "Is Friday the 13th Bad For YourHealth?," BMJ, 307, 1584-1586.
par(mfrow = c(1,2)) boxPlot(friday$sixth[friday $type == "traffic"], xlab = "sixth") boxPlot(friday$thirteenth[friday $type == "traffic"], xlab = "thirteenth") Analytical skills of young gifted children An investigator is interested in understanding the relationship, if any, between the analytical skills ofyoung gifted children and the following variables: father's IQ, mother's IQ, age in month when thechild first said ‘mummy' or ‘daddy', age in month when the child first counted to 10 successfully,average number of hours per week the child's mother or father reads to the child, average numberof hours per week the child watched an educational program on TV during the past three months,average number of hours per week the child watched cartoons on TV during the past three months.
The analytical skills are evaluated using a standard testing procedure, and the score on this test isused as the response variable.
Data were collected from schools in a large city on a set of thirty-six children who were identifiedas gifted children soon after they reached the age of four.
A data frame with 36 observations and 8 variables.
score Score in test of analytical skills.
fatheriq Father's IQ.
motheriq Mother's IQ.
speak Age in months when the child first said ‘mummy' or ‘daddy'.
count Age in months when the child first counted to 10 successfully.
read Average number of hours per week the child's mother or father reads to the child.
edutv Average number of hours per week the child watched an educational program on TV during the past three months.
cartoons Average number of hours per week the child watched cartoons on TV during the past three months.
Graybill, F.A. & Iyer, H.K., (1994) Regression Analysis: Concepts and Applications, Duxbury, p.
511-6.
histPlot(gifted$motheriq - gifted$fatheriq) lm(gifted$score gifted$motheriq + gifted$fatheriq + gifted$speak + gifted$count + gifted$read + gifted$edutv + gifted$cartoons) Election results for 2010 Governor races in the U.S.
Election results for 2010 Governor races in the U.S.
A data frame with 37 observations on the following 23 variables.
id Unique identifier for the race, which does not overlap with other 2010 races (see state State nameabbr State name abbreviationname1 Name of the winning candidateperc1 Percentage of vote for winning candidate (if more than one candidate)party1 Party of winning candidatevotes1 Number of votes for winning candidatename2 Name of candidate with second most votesperc2 Percentage of vote for candidate who came in secondparty2 Party of candidate with second most votesvotes2 Number of votes for candidate who came in secondname3 Name of candidate with third most votesperc3 Percentage of vote for candidate who came in thirdparty3 Party of candidate with third most votesvotes3 Number of votes for candidate who came in thirdname4 Name of candidate with fourth most votesperc4 Percentage of vote for candidate who came in fourthparty4 Party of candidate with fourth most votesvotes4 Number of votes for candidate who came in fourthname5 Name of candidate with fifth most votesperc5 Percentage of vote for candidate who came in fifthparty5 Party of candidate with fifth most votesvotes5 Number of votes for candidate who came in fifth Data was collected from MSNBC.com on November 9th, 2010.
Simulated data for analyzing the relationship between watching TVand grades This is a simulated data set to be used to estimate the relationship between number of hours perweek students watch TV and the grade they got in a statistics class.
A data frame with 25 observations on the following 2 variables.
TV Number of hours per week students watch TV.
Grades Grades students got in a statistics class (out of 100).
There are a few potential outliers in this data set. When analyzing the data one should consider how(if at all) these outliers may affect the estimates of correlation coefficient and regression parameters.
makeTube(gradesTV$TV, gradesTV$Grades, 1.5, type='robust', homosk=FALSE) lmPlot(gradesTV$TV, gradesTV$Grades, xAxis=4, xlab='time watching TV', Heart Transplant Data The Stanford University Heart Transplant Study was conducted to determine whether an experimen-tal heart transplant program increased lifespan. Each patient entering the program was designatedofficially a heart transplant candidate, meaning that he was gravely ill and would most likely benefitfrom a new heart. Then the actual heart transplant occurs between a few weeks to several monthsdepending on the availability of a donor. Very few candidates during this waiting period show im-provement and get deselected as a heart transplant candidate, but for the purposes of this experimentthose patients were kept in the data as continuing candidates.
A data frame with 103 observations on the following 8 variables.
id ID number of the patient.
acceptyear Year of acceptance as a heart transplant candidate.
age Age of the patient at the beginning of the study.
survived Survival status with levels alive and dead.
survtime Number of days patients were alive after the date they were determined to be a candidate for a heart transplant until the termination date of the study prior Whether or not the patient had prior surgery with levels yes and no.
transplant Transplant status with levels control (did not receive a transplant) and treatment (received a transplant).
wait Waiting Time for Transplant Turnbull B, Brown B, and Hu M (1974). "Survivorship of heart transplant data." Journal of theAmerican Statistical Association, vol. 69, pp. 74-80.
ylab = 'Survival Time (days)') mosaicplot( transplant + survived, data = heartTr) At the 1976 Pro Bowl, Ray Guy, a punter for the Oakland Raiders, punted a ball that hung mid-airlong enough for officials to question whether the pigskin was filled with helium. The ball was foundto be filled with air, but since then many have tossed around the idea that a helium-filled footballwould outdistance an air-filled one. Students at Ohio State University conducted an experiment totest this myth. They used two identical footballs, one air filled with air and one filled with helium.
Each football was kicked 39 times and the two footballs were alternated with each kick.
A data frame with 39 observations on the following 3 variables.
trial Trial number.
air Distance in years for air-filled football.
helium Distance in years for helium-filled football.
Lafferty, M. B. (1993), "OSU scientists get a kick out of sports controversy, "The Columbus Dis-patch (November, 21, 1993), B7.
Data and Story Library, par(mfrow = c(1,2)) boxPlot(helium$air, xlab = "air") boxPlot(helium$helium, xlab = "helium") Histogram or hollow histogram Create histograms and hollow histograms. This function permits easy color and appearance cus-tomization.
histPlot(x, col = fadeColor("black", "22"), border = "black", breaks = "default", probability = FALSE, hollow = FALSE, add = FALSE, lty = 2, lwd = 1, freqTable=FALSE, right=TRUE, axes = TRUE, xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, .) Numerical vector or a frequency table (matrix) where the first column representsthe observed values and the second column the frequencies. See also freqTableargument.
Shading of the histogram bins.
Color of histogram bin borders.
A vector for the bin boundaries or an approximate number of bins.
If FALSE, the frequency is plotted. If TRUE, then a probability density.
If TRUE, a hollow histogram will be created.
If TRUE, the histogram is added to the plot.
Line type. Applies only if hollow=TRUE.
Line width. Applies only if hollow=TRUE.
Set to TRUE if x is a frequency table.
Set to FALSE to assign values of x that fall on a bin margin to the left bin. Oth-erwise the ties default to the right bin.
If FALSE, the axes are not plotted.
Label for the x axis.
Label for the y axis.
Limits for the x axis.
Limits for the y axis.
Additional arguments to plot. If add is TRUE, these arguments are ignored.
histPlot(run10$time[run10$gender=='M'], probability=TRUE, xlim=c(30, 180), ylim=c(0, 0.025), hollow=TRUE) hollow=TRUE, lty=3, border='red') legend('topleft', col=c('black', 'red'), lty=2:3, legend=c('M','F')) histPlot(run10$time, col=fadeColor('yellow', '33'), border='darkblue', probability=TRUE, breaks=30, lwd=3) brks <- c(40, 50, 60, 65, 70, 75, 80, seq(82.5, 120, 2.5), 125, 130, 135, 140, 150, 160, 180) United States House of Representatives historical make-up The make-up of the United States House of Representatives every two years since 1789. The lastCongress included is the 112th Congress, which completes its term in 2013.
A data frame with 112 observations on the following 12 variables.
congress The number of that year's CongressyearStart Starting yearyearEnd Ending yearseats Total number of seatsp1 Name of the first political partynp1 Number of seats held by the first political partyp2 Name of the second political partynp2 Number of seats held by the second political partyother Othervac Vacancydel Delegateres Resident commissioner Office of the Clerk of the U.S. House of Representatives Party Divisions: Data for Congresses 1-111 was recorded from the website above on November 1st, 2010. It appearsthis page was later moved to where data for Congress 112 was recorded on April 21, 2011.
#=====> Examine two-party relationship since 1855 <=====# these <- 34:112 <- c("#EEDDBB", "#DDEEBB", "#DDDDDD", party <- c("#2222FF", "#FF2222") type="n", xlab="Year", ylab="Percent of House seats", ylim=c(11, 93)) rect(1861.3, -1000, 1865.3, 1000, col=COL[1], border="#FFFFFF") rect(1914.5, -1000, 1918.9, 1000, col=COL[2], border="#FFFFFF") rect(1929, -1000, 1939, 1000, col=COL[3], border="#FFFFFF") rect(1939.7, -1000, 1945.6, 1000, col=COL[4], border="#FFFFFF") rect(1955.8, -1000, 1965.3, 1000, col=COL[5], border="#E2E2E2") rect(1965.3, -1000, 1975.4, 1000, col=COL[6], border="#E2E2E2") legend("topleft", lty=c(1,1), col=party, c("Civil War", "World War I", "Great Depression", "World War II", "Vietnam War Start", "Vietnam War Escalated"), Election results for the 2010 U.S. House of Represenatives races Election results for the 2010 U.S. House of Represenatives races A data frame with 435 observations on the following 24 variables.
id Unique identifier for the race, which does not overlap with other 2010 races (see state State nameabbr State name abbreviationnum District number for the statename1 Name of the winning candidateperc1 Percentage of vote for winning candidate (if more than one candidate)party1 Party of winning candidatevotes1 Number of votes for winning candidatename2 Name of candidate with second most votesperc2 Percentage of vote for candidate who came in secondparty2 Party of candidate with second most votesvotes2 Number of votes for candidate who came in secondname3 Name of candidate with third most votesperc3 Percentage of vote for candidate who came in thirdparty3 Party of candidate with third most votesvotes3 Number of votes for candidate who came in thirdname4 Name of candidate with fourth most votesperc4 Percentage of vote for candidate who came in fourthparty4 Party of candidate with fourth most votesvotes4 Number of votes for candidate who came in fourthname5 Name of candidate with fifth most votesperc5 Percentage of vote for candidate who came in fifthparty5 Party of candidate with fifth most votesvotes5 Number of votes for candidate who came in fifth This analysis in the Examples section was inspired by and is similar to that of Nate Silver's district-level analysis on the FiveThirtyEight blog in the New York Times: Data was collected from MSNBC.com on November 9th, 2010.
hr <- table(houseRace10[,c("abbr", "party1")]) nr <- apply(hr, 1, sum) <- prRace08[prRace08$state != "DC",c("state", "pObama")] (fit <- glm(hr pr$pObama, family=binomial)) x1 <- pr$pObama[match(houseRace10$abbr, pr$state)] y1 <- (houseRace10$party1 == "Democrat")+0 g <- glm(y1 x1, family=binomial) x <- pr$pObama[pr$state != "DC"] nr <- apply(hr, 1, sum) plot(x, hr[,"Democrat"]/nr, pch=19, cex=sqrt(nr), col="#22558844", xlim=c(20, 80), ylim=c(0, 1), xlab="Percent vote for Obama in 2008", ylab="Probability of Democrat winning House seat") X <- seq(0, 100, 0.1) lo <- -5.6079 + 0.1009*X p <- exp(lo)/(1+exp(lo)) abline(h=0:1, lty=2, col="#888888") High School and Beyond survey Two hundred observations were randomly sampled from the High School and Beyond survey, asurvey conducted on high school seniors by the National Center of Education Statistics.
A data frame with 200 observations and 11 variables.
id Student ID.
gender Student's gender, with levels female and male.
race Student's race, with levels african american, asian, hispanic, and white.
ses Socio economic status of student's family, with levels low, middle, and high.
schtyp Type of school, with levels public and private.
prog Type of program, with levels general, academic, and vocational.
read Standardized reading score.
write Standardized writing score.
math Standardized math score.
science Standardized science score.
socst Standardized social studies score.
UCLA Academic Technology Services, boxPlot(hsb2$read - hsb2$write, fact = hsb2$gender, ylab = "diff. bet. reading and writing scores") Infant Mortality Rates, 2012 This entry gives the number of deaths of infants under one year old in 2012 per 1,000 live births inthe same year. This rate is often used as an indicator of the level of health in a country.
A data frame with 222 observations on the following 2 variables.
country Name of country.
infMortRate Infant mortality rate per 1,000 live births.
The data is given in decreasing order of infant mortality rates. There are a few potential outliers.
CIA World Factbook, Length of songs on an iPod A simulated data set on lengths of songs on an iPod.
A data frame with 3000 observations on the following variable.
songLength Length of song (in minutes).
Simulated data.
Linear regression plot with residual plot Plot data, the linear model, and a residual plot simultaneously.
lmPlot(x, y, xAxis = 0, yAxis = 4, resAxis = 3, resSymm = TRUE, wBox = TRUE, wLine = TRUE, lCol = "#00000088", lty = 1, lwd = 1, xlab = "", ylab = "", marRes = NULL, col = "#22558888", pch = 20, cex = 1.5, xR = 0.02, yR = 0.1, xlim = NULL, ylim = NULL, subset = NULL, parCustom = FALSE, myHeight = c(1, 0.45), plots = c("both", "mainOnly", "resOnly"), highlight = NULL, hlCol = NULL, hlCex = 1.5, hlPch = 20, na.rm=TRUE, .) The x coordinates of points in the plot.
The y coordinates of points in the plot.
The maximum number of x axis labels.
The maximum number of y axis labels.
The maximum number of y axis labels in the residual plot.
Boolean determining whether the range of the residual plot should be symmetricabout zero.
Boolean determining whether a box should be added around each plot.
Boolean determining whether to add a regression line to the plot.
The color of the regression line to be added.
The line type of the regression line to be added.
The line width of the regression line to be added.
A label for the x axis.
A label for the y axis Margin specified for the residuals.
Color of points.
Plotting character.
Plotting character size.
Scaling the limits of the x axis. Ignored if xlim specified.
Scaling the limits of the y axis. Ignored if ylim specified.
Limits for the x axis.
Limits for the y axis.
A subset of the data to be used for the linear model.
If TRUE, then the plotting margins are not modified automatically. This valueshould also be TRUE if the plots are being placed within a plot of multiple panels.
A numerical vector of length 2 representing the ratio of the primary plot to theresidual plot, in height.
Not currently utilized.
Numerical vector specifying particular points to highlight.
Color of highlighted points.
Size of highlighted points.
Plotting characters of highlighted points.
Remove cases with NA values.
Additional arguments to plot.
David M Diez <david.m.diez@gmail.com> lmPlot(gradesTV$TV, gradesTV$Grades, xAxis=4, xlab='time watching TV', yR=0.2, highlight=c(1,15,20)) Output a message while inside a loop Output a message while inside a for loop to update the user on progress. This function is useful intracking progress when the number of iterations is large or the procedures in each iteration take along time.
loop(i, n = NULL, every = 1, extra=NULL) The index value used in the loop.
The last entry in the loop.
The number of loops between messages.
Additional information to print.
loop(i, 160, 20, paste("iter", i)) Produce a linear, quadratic, or nonparametric tube for regression data.
makeTube(x, y, Z=2, R=1, col='#00000022', border='#00000000', type=c('lin', 'quad', 'robust'), stDev=c('constant', 'linear', 'other'), length.out=99, bw='default', plotTube=TRUE, addLine=TRUE, .) x coordinates.
y coordinates.
Number of standard deviations out from the regression line to extend the tube.
Control of how far the tube extends to the left and right.
Fill color of the tube.
Border color of the tube.
The type of model fit to the data. Here 'robust' results in a nonparametricestimate.
Choices are constant variance ('constant'), the standard deviation of the errorschanges linearly ('linear'), or the standard deviation of the errors should beestimated using nonparametric methods ('other').
The number of observations used to build the regression model. This argumentmay be increased to increase the smoothing of a quadratic or nonparametriccurve.
Bandwidth used if type='robust' or homosk=FALSE.
Whether the tube should be plotted.
Whether the linear model should be plotted.
Additional arguments passed to the lines function if addLine=TRUE.
x coordinates for the regression model.
y coordinates for the regression model.
x coordinates for the boundary of the tube.
y coordinates for the boundary of the tube.
#===> possum example <===# x <- possum$totalL y <- possum$headL #===> Grades and TV example <===# makeTube(gradesTV$TV, gradesTV$Grades, 1.5) makeTube(gradesTV$TV, gradesTV$Grades, 1.5, stDev='o') makeTube(gradesTV$TV, gradesTV$Grades, 1.5, type='robust') makeTube(gradesTV$TV, gradesTV$Grades, 1.5, type='robust', stDev='o') #===> What can go wrong with a basic least squares model <===# par(mfrow=c(1,3), mar=c(2.5, 2.5, 1, 2.5)) x <- runif(100) y <- 25*x-20*x 2+rnorm(length(x), sd=1.5) x <- c(-0.6, -0.46, -0.091, runif(97)) y <- 25*x + rnorm(length(x)) y[2] <- y[2] + 8 y[1] <- y[1] + 1 x <- runif(100) y <- 5*x + rnorm(length(x), sd=x) makeTube(x, y, stDev='l', bw=0.03) This data set includes data for 39 species of mammals distributed over 13 orders. The data wereused for analyzing the relationship between constitutional and ecological factors and sleeping inmammals. Two qualitatively different sleep variables (dreaming and non dreaming) were recorded.
Constitutional variables such as life span, body weight, brain weight and gestation time were evalu-ated. Ecological variables such as severity of predation, safety of sleeping place and overall dangerwere inferred from field observations in the literature.
A data frame with 62 observations on the following 11 variables.
Species Species of mammalsBodyWt Total body weight of the mammal (in kg)BrainWt Brain weight of the mammal (in kg)NonDreaming Number of hours of non dreaming sleepDreaming Number of hours of dreaming sleepTotalSleep Total number of hours of sleepLifeSpan Life span (in years)Gestation Gestation time (in days)Predation An index of how likely the mammal is to be preyed upon. 1 = least likely to be preyed upon. 5 = most likely to be preyed upon.
Exposure An index of the how exposed the mammal is during sleep. 1 = least exposed (e.g., sleeps in a well-protected den). 5 = most exposed.
Danger An index of how much danger the mammal faces from other animals. This index is based upon Predation and Exposure. 1 = least danger from other animals. 5 = most danger fromother animals.
T. Allison and D. Cicchetti, "Sleep in mammals: ecological and constitutional correlates," Arch.
Hydrobiol, vol. 75, p. 442, 1975.
New York City Marathon Times Marathon times of male and female winners of the New York City Marathon 1970-1999.
A data frame with 60 observations on the following 3 variables.
Year YearGender GenderTime Running time (in hours) boxPlot(marathon$Time, horiz = TRUE, fact = marathon$Gender) Wii Mario Kart auctions from Ebay Auction data from Ebay for the game Mario Kart for the Nintendo Wii. This data was collected inearly October, 2009.
A data frame with 143 observations on the following 12 variables. All prices are in US dollars.
ID Auction ID assigned by Ebay.
duration Auction length, in days.
nBids Number of bids.
cond Game condition, either new or used.
startPr Start price of the auction.
shipPr Shipping price.
totalPr Total price, which equals the auction price plus the shipping price.
shipSp Shipping speed or method.
sellerRate The seller's rating on Ebay. This is the number of positive ratings minus the number of negative ratings for the seller.
stockPhoto Whether the auction feature photo was a stock photo or not. If the picture was used in many auctions, then it was called a stock photo.
wheels Number of Wii wheels included in the auction. These are steering wheel attachments to make it seem as though you are actually driving in the game. When used with the controller,turning the wheel actually causes the character on screen to turn.
title The title of the auctions.
There are several interesting features in the data. First off, note that there are two outliers in thedata, as shown below. These serve as a nice example of what one should do when encountering anoutlier: examine the data point and remove it only if there is a good reason. In these two cases,we can see from the auction titles that they included other items in their auctions besides the game,which justifies removing them from the data set.
This data set includes all auctions for a full week in October, 2009. Auctions were included in thedata set if they satisfied a number of conditions. (1) They were included in a search for "wii mariokart" on ebay.com, (2) items were in the Video Games > Games > Nintendo Wii section of Ebay, (3) the listing was an auction and not exclusively a "Buy it Now" listing (sellers sometimes offeran optional higher price for a buyer to end bidding and win the auction immediately, which is anoptional Buy it Now auction), (4) the item listed was the actual game, (5) the item was being soldfrom the US, (6) the item had at least one bidder, (7) there were no other items included in theauction with the exception of racing wheels, either generic or brand-name being acceptable, and (8)the auction did not end with a Buy It Now option.
#===> Identify the outliers <===# toss <- which(marioKart$totalPr > 80) lines(rep(marioKart$totalPr[toss[1]], 2), c(2.4, 2)) lines(rep(marioKart$totalPr[toss[2]], 2), c(1.6, 2)) marioKart[toss, ] # the other two points marked on the boxplot are legitimate auctions #===> Replot without the outliers <===# #===> Fit a Multiple Regression Model <===# mk <- marioKart[-toss,] summary(lm(totalPr cond + stockPhoto + duration + wheels, mk)) summary(lm(totalPr cond + stockPhoto + wheels, mk)) summary(fit <- lm(totalPr cond + wheels, mk)) #===> Fit Diagnostics <===# par(mfrow=c(2,3), mar=c(4, 4, 2, 1)) plot(e, xlab="Order of collection", ylab="Residuals") plot(f, e, xlab="Fitted values", ylab="Residuals") plot(f, (abs(e)), xlab="Fitted values", ylab="Absolute value of residuals") boxPlot(e, mk$cond, xlab="Condition", ylab="Residuals") plot(mk$wheels, e, xlab="Number of wheels", ylab="Residuals", Salary data for Major League Baseball (2010) Salary data for Major League Baseball players in the year 2010.
A data frame with 828 observations on the following 4 variables.
player Player nameteam Teamposition Field positionsalary Salary (in $1000s) Collected from the following page (and its linked pages) on February 23rd, 2011: #=====> Basic Histogram <=====# hist(MLB$salary/1000, main="", breaks=15, xlab="Salary (millions of dollars)", axes=FALSE, ylab="", col="#22558844") axis(1, seq(0, 40, 10)) axis(2, c(0, 500)) axis(2, seq(100, 400, 100), rep("", 4), tcl=-0.2) #=====> Histogram on Log Scale <=====# hist(log(MLB$salary/1000), main="", breaks=15, xlab="log(Salary)", axes=FALSE, ylab="", col="#22558844") axis(1) #, seq(0, 40, 10)) axis(2, seq(0, 300, 100)) #=====> Box plot of log(salary) against position <=====# par(las=1, mar=c(4, 8, 1, 1)) boxPlot(log(MLB$salary/1000), MLB$position, horiz=TRUE, ylab="") Major League Baseball Player Hitting Statistics for 2010 Major League Baseball Player Hitting Statistics for 2010.
A data frame with 1199 observations on the following 19 variables.
name Player nameteam Team abbreviationposition Player positionG Number of gamesAB Number of at batsR Number of runsH Number of hits2B Number of doubles3B Number of triplesHR Number of home runsRBI Number of runs batted inTB Total bases, computed as 3*HR + 2*3B + 1*2B + HBB Number of walksSO Number of strikeoutsSB Number of stolen basesCS Number of times caught stealingOBP On base percentageSLG Slugging percentage (TB / AB)AVG Batting average Data was collected from MLB.com on April 22nd, 2011.
<- mlbBat10[mlbBat10$AB > 200,] pos <- list(c("OF"), c("1B", "2B", "3B", "SS"), "DH", "C") POS <- c("OF", "IF", "DH", "C") #=====> On-base Percentage Across Positions <=====# for(i in 1:length(pos)){ these <- which(d$pos %in% pos[[i]]) <- c(out, d[these,"OBP"]) <- c(gp, rep(POS[i], length(these))) }plot(out as.factor(gp)) #=====> Batting Average Across Positions <=====# for(i in 1:length(pos)){ these <- which(d$pos %in% pos[[i]]) <- c(out, d[these,"AVG"]) <- c(gp, rep(POS[i], length(these))) }plot(out as.factor(gp)) #=====> Home Runs Across Positions <=====# for(i in 1:length(pos)){ these <- which(d$pos %in% pos[[i]]) <- c(out, d[these,"HR"]) <- c(gp, rep(POS[i], length(these))) }plot(out as.factor(gp)) #=====> Runs Batted In Across Positions <=====# for(i in 1:length(pos)){ these <- which(d$pos %in% pos[[i]]) <- c(out, d[these,"RBI"]) <- c(gp, rep(POS[i], length(these))) }plot(out as.factor(gp)) Custom PDF function A similar function to pdf and png, except that different defaults are provided, including for theplotting parameters.
myPDF(fileName, width = 5, height = 3, mar = c(3.9, 3.9, 1, 1), mgp = c(2.8, 0.55, 0), las = 1, tcl=-0.3, .) myPNG(fileName, width = 600, height = 400, mar = c(3.9, 3.9, 1, 1), mgp = c(2.8, 0.55, 0), las = 1, tcl=-0.3, .) File name for the image to be output. The name should end in .pdf.
The width of the image file (inches). Default: 5.
The height of the image file (inches). Default: 3.
Plotting margins. To change, input a numerical vector of length 4.
Margin graphing parameters. To change, input a numerical vector of length 3.
The first argument specifies where x and y labels are placed; the second specifiesthe axis labels are placed; and the third specifies how far to pull the entire axisfrom the plot.
Orientation of axis labels. Input 0 for the default.
The tick mark length as a proportion of text height. The default is -0.5.
Additional arguments to par.
#=====> Save a plot to a PDF <=====# #=====> Save a plot to a PNG <=====# North Carolina births In 2004, the state of North Carolina released to the public a large data set containing informationon births recorded in this state. This data set has been of interest to medical researchers whoare studying the relation between habits and practices of expectant mothers and the birth of theirchildren. This is a random sample of 1,000 cases from this data set.
A data frame with 1000 observations on the following 13 variables.
fage Father's age in years.
mage Mother's age in years.
mature Maturity status of mother.
weeks Length of pregnancy in weeks.
premie Whether the birth was classified as premature (premie) or full-term.
visits Number of hospital visits during pregnancy.
gained Weight gained by mother during pregnancy in pounds.
weight Weight of the baby at birth in pounds.
lowbirthweight Whether baby was classified as low birthweight (low) or not (not low).
gender Gender of the baby, female or male.
habit Status of the mother as a nonsmoker or a smoker.
marital Whether mother is married or not married at birth.
whitemom Whether mom is white or not white.
boxPlot(ncbirths$weight, fact = ncbirths$habit) boxPlot(ncbirths$visits, fact = ncbirths$whitemom) boxPlot(ncbirths$gained, fact = ncbirths$mature) Normal distribution tails Produce a normal (or t) distribution and shaded tail.
normTail(m = 0, s = 1, L = NULL, U = NULL, M = NULL, df=1000, curveColor=1, border = 1, col = "#CCCCCC", xlim = NULL, ylim=NULL, xlab = "", ylab = "", digits = 2, axes = 1, detail = 999, xLab = c("number", "symbol"), cex.axis = 1, Numerical value for the distribution mean.
Numerical value for the distribution standard deviation.
Numerical value representing the cutoff for a shaded lower tail.
Numerical value representing the cutoff for a shaded upper tail.
Numerical value representing the cutoff for a shaded central region.
Numerical value describing the degrees of freedom. Default is 1000, whichresults in a nearly normal distribution. Small values may be useful to emphasizesmall tails.
The color for the distribution curve.
The color for the border of the shaded area.
The color for filling the shaded area.
Limits for the x axis.
Limits for the y axis.
A title for the x axis.
A title for the y axis.
The maximum number of digits past the decimal to use in axes values.
A numeric value denoting whether to draw both axes (3), only the vertical axes(2), only the horizontal axes (1, the default), or no axes (0).
A number describing the number of points to use in drawing the normal curve.
Smaller values correspond to a less smooth curve but reduced memory usage inthe final file.
If "number", then the axis is drawn at the mean, and every standard deviationout until the third standard deviation. If "symbol", then Greek letters are usedfor standard deviations from three standard deviations from the mean.
Numerical value controlling the size of the axis labels.
A number describing how often axis labels are placed, scaled by standard devi-ations. This argument is ignored if xLab="symbol".
Additional arguments to plot.
normTail(3,2,M=1:2, xLab='symbol', cex.axis=0.8) normTail(L=-1, U=2, M=c(0,1), axes=3, xAxisIncr=2) normTail(L=-1, U=2, M=c(0,1), xLab='symbol', cex.axis=0.8, xAxisIncr=2) Oscar winners, 1929 to 2012 Best actor and actress Oscar winners from 1929 to 2012.
A data frame with 170 observations on the following 10 variables.
gender Gender of winner, female or male.
oscar_no Denotes which Oscar ceremony.
oscar_yr Denotes which Oscar year.
name Name of winning actor or actress.
movie Name of movie actor or actress got the Oscar for.
age Age at which the actor or actress won the Oscar.
birth_pl State where the actor or actress was born, country if foreign.
birth_mo Birth month of actor or actress.
birth_d Birth day of actor or actress.
birth_y Birth year of actor or actress.
Although there have been only 84 Oscar ceremonies until 2012, there are 85 male winners and 85female winners because ties happened on two occasions (1933 for the best actor and 1969 for thebest actress).
Journal of Statistical Education, updated through 2012 using information from Wikipedia.org.
Poker winnings during 50 sessions Poker winnings (and losses) for 50 days by a professional poker player.
A data frame with 49 observations on the following variable.
winnings Poker winnings and losses, in US dollars.
Anonymity has been requested by the player.
Data representing possums in Australia and New Guinea. This is a copy of the data set by the samename in the DAAG package, however, the data set included here includes fewer variables.
A data frame with 104 observations on the following 8 variables.
site The site number where the possum was trapped.
pop Population, either Vic (Victoria) or other (New South Wales or Queensland).
sex Gender, either m (male) or f (female).
age Age.
headL Head length, in mm.
skullW Skull width, in mm.
totalL Total length, in cm.
tailL Tail length, in cm.
Lindenmayer, D. B., Viggers, K. L., Cunningham, R. B., and Donnelly, C. F. 1995. Morphologicalvariation among columns of the mountain brushtail possum, Trichosurus caninus Ogilby (Phalan-geridae: Marsupiala). Australian Journal of Zoology 43: 449-458.
xlab='total length (cm)') legend('topright', col=c('black', 'red'), lty=1:2, legend=c('f', 'm')) United States Presidental History Summary of the changes in the president and vice president for the United States of America.
A data frame with 67 observations on the following 5 variables.
potus President of the United Statesparty Political party of the presidentstart Start yearend End yearvpotus Vice President of the United States Presidents of the United States (table) – infoplease.com (visited: Nov 2nd, 2010) Election results for the 2008 U.S. Presidential race Election results for the 2008 U.S. Presidential race A data frame with 51 observations on the following 7 variables.
state State name abbreviationstateFull Full state namenObama Number of votes for Barack ObamapObama Proportion of votes for Barack ObamanMcCain Number of votes for John McCainpMcCain Proportion of votes for John McCainelVotes Number of electoral votes for a state In Nebraska, 4 electoral votes went to McCain and 1 to Obama. Otherwise the electoral votes werea winner-take-all.
Presidential Election of 2008, Electoral and Popular Vote Summary, collected on April 21, 2011from #===> Obtain 2010 US House Election Data <===# hr <- table(houseRace10[,c("abbr", "party1")]) nr <- apply(hr, 1, sum) #===> Obtain 2008 President Election Data <===# <- prRace08[prRace08$state != "DC",c("state", "pObama")] (fit <- glm(hr pr$pObama, family=binomial)) #===> Visualizing Binomial outcomes <===# x <- pr$pObama[pr$state != "DC"] nr <- apply(hr, 1, sum) plot(x, hr[,"Democrat"]/nr, pch=19, cex=sqrt(nr), col="#22558844", xlim=c(20, 80), ylim=c(0, 1), xlab="Percent vote for Obama in 2008", ylab="Probability of Democrat winning House seat") #===> Logistic Regression <===# x1 <- pr$pObama[match(houseRace10$abbr, pr$state)] y1 <- (houseRace10$party1 == "Democrat")+0 g <- glm(y1 x1, family=binomial) X <- seq(0, 100, 0.1) lo <- -5.6079 + 0.1009*X p <- exp(lo)/(1+exp(lo)) abline(h=0:1, lty=2, col="#888888") Cherry Blossom 10 mile run data, 2009 14 variables for all 14,974 10 mile participants in the 2009 Cherry Blossom Run (run10_09) and 9variables for all 16,924 participants in 2012.
The run10_09 data frame summarizes 14,974 observations on the following 14 variables. The run10 (2012 data) summarizes 16,924 observations on 9 variables, which are featured with anasterisk.
place * Finishing position. Separate positions are provided for each gender.
time * The total run time. For run10, this is equivalent to netTime.
netTime The run time from the start line to the finish line.
pace * The listed pace for each runner.
age * Age.
gender * Gender.
first First name.
last Last name.
city Hometown city.
location * Hometown city. (run10 data only.)state * Hometown state. (For run10, this may also list a country.)country Hometown country.
div Running division (age group).
divPlace * Division place, also broken up by gender.
divTot * Total number of people in the division (again, also split by gender).
OpenIntro Statistics #===> men's times <===# histPlot(run10$time[run10$gender == 'M']) #===> times by gender <===# legend('topright', lty=2:1, col=c('red','black'), #===> Examine Sample <===# SAT and GPA data for 1000 students at an unnamed college.
A data frame with 1000 observations on the following 6 variables.
sex Gender of the student.
SATV Verbal SAT percentile.
SATM Math SAT percentile.
SATSum Total of verbal and math SAT percentiles.
HSGPA High school grade point average.
FYGPA First year (college) grade point average.
Educational Testing Service originally collected the data.
Data retrieved fromData utilized in Chapter 7 of the Open Intro Statistics book: g <- lm(satGPA$FYGPA I(satGPA$SATSum/2)) g <- lm(satGPA$FYGPA satGPA$SATM) Election results for the 2010 U.S. Senate races Election results for the 2010 U.S. Senate races A data frame with 38 observations on the following 23 variables.
id Unique identifier for the race, which does not overlap with other 2010 races (see state State nameabbr State name abbreviationname1 Name of the winning candidateperc1 Percentage of vote for winning candidate (if more than one candidate)party1 Party of winning candidatevotes1 Number of votes for winning candidatename2 Name of candidate with second most votesperc2 Percentage of vote for candidate who came in secondparty2 Party of candidate with second most votesvotes2 Number of votes for candidate who came in secondname3 Name of candidate with third most votesperc3 Percentage of vote for candidate who came in thirdparty3 Party of candidate with third most votesvotes3 Number of votes for candidate who came in thirdname4 Name of candidate with fourth most votesperc4 Percentage of vote for candidate who came in fourthparty4 Party of candidate with fourth most votesvotes4 Number of votes for candidate who came in fourthname5 Name of candidate with fifth most votesperc5 Percentage of vote for candidate who came in fifthparty5 Party of candidate with fifth most votesvotes5 Number of votes for candidate who came in fifth Data was collected from MSNBC.com on November 9th, 2010.
histPlot(senateRace10$perc1, xlab="Winning candidate vote percentage") Survey data on smoking habits from the UK. The data set can be used for analyzing the demographiccharacteristics of smokers and types of tobacco consumed.
A data frame with 1691 observations on the following 12 variables.
gender Gender with levels Female and Male.
age Age.
maritalStatus Marital status with levels Divorced, Married, Separated, Single and Widowed.
highestQualification Highest education level with levels A Levels, Degree, GCSE/CSE, GCSE/O Level, Higher/Sub Degree, No Qualification, ONC/BTEC and Other/Sub Degree nationality Nationality with levels British, English, Irish, Scottish, Welsh, Other, Refused and Unknown.
ethnicity Ethnicity with levels Asian, Black, Chinese, Mixed, White and Refused Unknown.
grossIncome Gross income with levels Under 2,600, 2,600 to 5,200, 5,200 to 10,400, 10,400 to 15,600, 15,600 to 20,800, 20,800 to 28,600, 28,600 to 36,400, Above 36,400, Refused and Unknown.
region Region with levels London, Midlands & East Anglia, Scotland, South East, South West, The North and Wales smoke Smoking status with levels No and YesamtWeekends Number of cigarettes smoked per day on weekends.
amtWeekdays Number of cigarettes smoked per day on weekdays.
type Type of cigarettes smoked with levels Packets, Hand-Rolled, Both/Mainly Packets and Both/Mainly Hand-Rolled mosaicplot( smoke + maritalStatus, data = smoking) barplot(sort(table(smoking$maritalStatus), decreasing = TRUE)) Textbook data for UCLA Bookstore and Amazon A random sample was taken of nearly 10% of UCLA courses. The most expensive textbook foreach course was identified, and its new price at the UCLA Bookstore and on Amazon.com wererecorded.
A data frame with 73 observations on the following 7 variables.
deptAbbr Course department (abbreviated).
course Course number.
ibsn Book ISBN.
uclaNew New price at the UCLA Bookstore.
amazNew New price on Amazon.com.
more Whether additional books were required for the course (Y means "yes, additional books were diff The UCLA Bookstore price minus the Amazon.com price for each book.
The sample represents only courses where textbooks were listed online through UCLA Bookstore'swebsite. The most expensive textbook was selected based on the UCLA Bookstore price, whichmay insert bias into the data; for this reason, it may be beneficial to analyze only the data wheremore is "N".
This data was collected by David M Diez on April 24th.
See Section 5.1 of the Open Intro Statistics textbook: #===> an improper analysis <===# axis(1, at=1:2, labels=c('UCLA Bookstore', 'Amazon')) #===> a reasonable analysis <===# the differences are moderately skewed the sample size is sufficiently large to justify t test Thanksgiving spending, simulated based on Gallup poll.
This entry gives simulated spending data for Americans during Thanksgiving in 2009 based onfindings of a Gallup poll.
A data frame with 436 observations on the following 1 variable.
spending Amount of spending, in US dollars.
A simulated data set of tips over a few weeks on a couple days per week. Each tip is associatedwith a single group, which may include several bills and tables (i.e. groups paid in one lump sumin simulations).
A data frame with 95 observations on the following 5 variables.
week Week number.
day Day, either Friday or Tuesday.
nPeop Number of people associated with the group.
bill Total bill for the group.
tip Total tip from the group.
This data set was built using simulations of tables, then bills, then tips based on the bills. Largegroups were assumed to only pay the gratuity, which is evident in the data. Tips were set to beplausible round values; they were often (but not always) rounded to dollars, quarters, etc.
Simulated data set.
densityPlot(tips$tip, tips$week, key=1:3) legend('topright', lty=1:3, col=c('black', 'red', 'blue'), legend=1:3) legend('topright', col=c('black','red'), lty=1:2, Construct tree diagrams Construct beautiful tree diagrams treeDiag(main, p1, p2, out1 = c("Yes", "No"), out2 = c("Yes", "No"), textwd = 0.15, solwd = 0.2, SBS = c(TRUE, TRUE), showSol = TRUE, solSub = NULL, digits = 4, textadj = 0.015, cex.main = 1.3, col.main = "#999999", showWork = FALSE) Character vector with two variable names, descriptions, or questions Vector of probabilities for the primary branches List for the secondary branches, where each list item should be a numericalvector of probabilities corresponding to the primary branches of p1 Character vector of the outcomes corresponding to the primary branches Character vector of the outcomes corresponding to the secondary branches The width provided for text with a default of 0.15 The with provided for the solution with a default of 0.2 A boolean vector indicating whether to place text and probability side-by-sidefor the primary and secondary branches Boolean indicating whether to show the solution in the tree diagram An optional list of vectors corresponding to p2 to list alternative text or solutions The number of digits to show in the solution Vertical adjustment of text Size of main in the plot Color of main in the plot Whether work should be shown for the solutions No value is given. A sample plot is given below: David M Diez, Christopher D Barr OpenIntro Statistics, Chapter 2.
# generic with random probabilities treeDiag(c('Flight on time?','Luggage on time?'), c(.8,.2), list(c(.97,.03), c(.15,.85))) treeDiag(c('Breakfast?','Go to class'), c(.4,.6), treeDiag(c('Breakfast?','Go to class'), c(.4,.11,.49), treeDiag(c('Dow Jones rise?', 'NASDAQ rise?'), c(0.53, 0.47), list(c(0.75, 0.25), c(0.72, 0.28)), solSub=list(c("(a)", "(b)"), c("(c)", "(d)")), solwd=0.08) Annual unemployment since 1890 A compilation of two data sets that provides an estimate of unemployment from 1890 to 2010.
A data frame with 121 observations on the following 3 variables.
year Yearunemp Unemployment rate, in percentusData 1 if from the Bureau of Labor Statistics, 0 otherwise The data are from Wikipedia at the following URL accessed on November 1st, 2010:Below is a direct quotation from Wikipedia describing the sources of the data: Own work by Peace01234 Complete raw data are on Peace01234. 1930-2009 data are from Bureauof Labor Statistics, Employment status of the civilian noninstitutional population, 1940 to dateftp://ftp.bls.gov/pub/special.requests/lf/aat1.txt, retrieved March 6, 2009 and [1] retrieved February12, 2010. Data prior to 1948 are for persons age 14 and over. Data beginning in 1948 are forpersons age 16 and over. See also "Historical Comparability" under the Household Data section ofthe Explanatory Notes at 1890-1930 data arefrom Christina Romer (1986). "Spurious Volatility in Historical Unemployment Data", The Journalof Political Economy, 94(1): 1-37. 1930-1940 data are from Robert M. Coen (1973). "Labor Forceand Unemployment in the 1920's and 1930's: A Re-Examination Based on Postwar Experience",The Review of Economics and Statistics, 55(1): 46-55. Unemployment data was only surveyedonce each decade until 1940 when yearly surveys were begun. The yearly data estimates before1940 are based on the decade surveys combined with other relevant surveys that were collectedduring those years. The methods are described in detail by Coen and Romer.
#=====> Time Series Plot of Data <=====# <- c("#DDEEBB", "#EEDDBB", "#BBDDEE", "#FFD5DD", "#FFC5CC") plot(unempl$year, unempl$unemp, type="n") rect(0, -50, 3000, 100, col="#E2E2E2") rect(1914.5, -1000, 1918.9, 1000, col=COL[1], border="#E2E2E2") rect(1929, -1000, 1939, 1000, col=COL[2], border="#E2E2E2") rect(1939.7, -1000, 1945.6, 1000, col=COL[3], border="#E2E2E2") rect(1955.8, -1000, 1965.3, 1000, col=COL[4], border="#E2E2E2") rect(1965.3, -1000, 1975.4, 1000, col=COL[5], border="#E2E2E2") abline(v=seq(1900, 2000, 20), col="#FFFFFF", lwd=1.3) points(unempl$year, unempl$unemp, pch=20) c("World War I", "Great Depression", "World War II", "Vietnam War Start", "Vietnam War Escalated"), ∗Topic customize axis ∗Topic Abbreviation ∗Topic datasets, ball bearings, ∗Topic Bayes Theorem inference on means ∗Topic Conditional probability ∗Topic datasets, college credits, inference on means ∗Topic Data tube ∗Topic datasets, correlation, ∗Topic Graphics ∗Topic Kernel smoothing ∗Topic datasets, histogram, ∗Topic Least squares ∗Topic datasets, iPod, inference on ∗Topic datasets, regression ∗Topic Plotting ∗Topic datasets, smoking ∗Topic Regression ∗Topic datasets ∗Topic Tree diagram ∗Topic United States ∗Topic categorical data ∗Topic contingency tables ∗Topic control axis ∗Topic election createEdaOptions (edaPlot), ∗Topic for loop ∗Topic heart transplant ∗Topic linear model email_test (email), guessMethod (edaPlot), openintro-package, ∗Topic president ∗Topic randomization tests ∗Topic residuals makePlotIcon (edaPlot), openintro (openintro-package), openintro-package, plotNothing (edaPlot), run10_09 (run10), run10Samp (run10), state2abbr (abbr2state),

Source: https://cran.ism.ac.jp/web/packages/openintro/openintro.pdf

Strength of recommendation taxonomy (sort): a patient-centered approach to grading evidence in the medical literature - american family physician

Strength of Recommendation Taxonomy (SORT): A Patient-Centered Approach to Grading Evidence in the Medical LiteratureMARK H. EBELL M.D., M.S., Michigan State University College of Human Medicine, East Lansing, MichiganJAY SIWEK, M.D., Georgetown University Medical Center, Washington, D.C.BARRY D. WEISS, M.D., University of Arizona College of Medicine, Tucson, ArizonaSTEVEN H. WOOLF, M.D., M.P.H., Virginia Commonwealth University School of Medicine, Richmond, VirginiaJEFFREY SUSMAN, M.D., University of Cincinnati College of Medicine, Cincinnati, OhioBERNARD EWIGMAN, M.D., M.P.H., University of Chicago, Pritzker School of Medicine, Chicago, IllinoisMARJORIE BOWMAN, M.D., M.P.A., University of Pennsylvania Health System, Philadelphia, Pennsylvania

National audit of seizure management in hospitals

National Audit of Seizure Management in Hospitals St. Elsewhere's Hospital Clinical Report, April 2014 2013 NASH Audit Report Prepared by: Professor Mike Pearson, Professor of Clinical Evaluation Professor Tony Marson, Professor of Neurology Pete Dixon, NASH Study Coordinator Karen Scott, NASH Study Administrator The National Audit of Seizure Management in Hospitals is funded by Eisai Ltd, UCB Pharma, Viropharma and University of Liverpool.