Learn R Programming

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

fastR2

This package contains data sets and some utility functions to support Foundations and Applications of Statistics: An Introduction Using R by Randall Pruim.

Installation

The package can be installed from CRAN via

install.packages("fastR2")

or from github

devtools::install_github("rpruim/fastR2")

Snippets

In addtion to data sets, fastR2 contains a snippet() function that loads and executes code found in the text. Here is an example:

require(fastR2)
require(multcomp)
snippet("bugs")
#> 
#> ## snippet: bugs
#> 
#> > model <- aov(sqrt(trapped) ~ color, data = Bugs)
#> 
#> > TukeyHSD(model)
#>   Tukey multiple comparisons of means
#>     95% family-wise confidence level
#> 
#> Fit: aov(formula = sqrt(trapped) ~ color, data = Bugs)
#> 
#> $color
#>          diff        lwr        upr     p adj
#> G-B  1.750330  0.6458303  2.8548288 0.0013396
#> W-B  0.146892 -0.9576072  1.2513913 0.9818933
#> Y-B  3.060201  1.9557018  4.1647003 0.0000011
#> W-G -1.603438 -2.7079368 -0.4989383 0.0031308
#> Y-G  1.309872  0.2053723  2.4143708 0.0165743
#> Y-W  2.913309  1.8088098  4.0178083 0.0000022
#> 
#> 
#> > model <- lm(sqrt(trapped) ~ color, data = Bugs)
#> 
#> > glht(model, mcp(color = "Tukey")) %>%
#> +   summary()          
#> 
#> 	 Simultaneous Tests for General Linear Hypotheses
#> 
#> Multiple Comparisons of Means: Tukey Contrasts
#> 
#> 
#> Fit: lm(formula = sqrt(trapped) ~ color, data = Bugs)
#> 
#> Linear Hypotheses:
#>            Estimate Std. Error t value Pr(>|t|)    
#> G - B == 0   1.7503     0.3946   4.436  0.00136 ** 
#> W - B == 0   0.1469     0.3946   0.372  0.98189    
#> Y - B == 0   3.0602     0.3946   7.755  < 0.001 ***
#> W - G == 0  -1.6034     0.3946  -4.063  0.00312 ** 
#> Y - G == 0   1.3099     0.3946   3.319  0.01672 *  
#> Y - W == 0   2.9133     0.3946   7.383  < 0.001 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> (Adjusted p values reported -- single-step method)
#> 
#> 
#> ## snippet: fit-bugs-pois01
#> 
#> > o <- c(2, 10, 16, 11, 5, 3, 3)
#> 
#> > o.collapsed <- c(2 + 10, 16, 11, 5, 3 + 3)
#> 
#> > n <- sum(o)
#> 
#> > m <- sum(o * 0:6) / n     # mean count = MLE for lambda (full data)
#> 
#> > p <- dpois(0:6, m)  
#> 
#> > p.collapsed <- c(p[1] + p[2], p[3:5], 1 - sum(p[1:5]))   # collapsed probs
#> 
#> > e.collapsed <- p.collapsed * n
#> 
#> > cbind(o.collapsed, p.collapsed, e.collapsed)
#>      o.collapsed p.collapsed e.collapsed
#> [1,]          12   0.2752049   13.760244
#> [2,]          16   0.2533122   12.665609
#> [3,]          11   0.2161597   10.807986
#> [4,]           5   0.1383422    6.917111
#> [5,]           6   0.1169810    5.849050
#> 
#> > lrt  <- 2 * sum(o.collapsed * log(o.collapsed / e.collapsed)); lrt
#> [1] 1.640881
#> 
#> > pearson <- sum((o.collapsed - e.collapsed)^2 / e.collapsed); pearson
#> [1] 1.641642
#> 
#> > 1-pchisq(lrt, df = 3)
#> [1] 0.6501564
#> 
#> > 1-pchisq(pearson, df = 3)
#> [1] 0.6499852
#> 
#> ## snippet: fit-bugs-pois02
#> 
#> > 1-pchisq(pearson, df = 5-1)
#> [1] 0.8012892
#> 
#> > 1-pchisq(pearson, df = 5-1-1)
#> [1] 0.6499852

Copy Link

Version

Install

install.packages('fastR2')

Monthly Downloads

366

Version

0.2.0

License

GPL (>= 2)

Maintainer

Randall Pruim

Last Published

August 30th, 2017

Functions in fastR2 (0.2.0)

ACTgpa

ACT scores and GPA
AirPollution

Air pollution measurements
Pheno

FUSION type 2 diabetes study
FamilySmoking

Family smoking
NCAAbb

NCAA Division I Basketball Results
NFL2007

NFL 2007 season
CoolingWater

Cooling Water
Corn

Corn Yield
GooosePermits

Goose permits
HeliumFootballs

Punting helium- and air-filled footballs
Jordan8687

Michael Jordan personal scoring
Batting

Major League Batting 2000-2005
Buckthorn

Buckthorn
Cuckoo

Cuckoo eggs in other birds' nests
DeathPenalty

Death Penalty and Race
Punting

American football punting
RatPoison

Rat poison -- unfinished documentation
Scent

Maze tracing and scents
Soap

Dwindling soap
Unemployment

Unemployment data
WorkingWomen

Women in the workforce
information

Information
maxLik2

Augmented version of maxLik
Bugs

Bugs
Concrete

Concrete Compressive Strength Data
Drag

Drag force experiment
Endurance

Endurance and vitamin C
LittleSurvey

Results from a little survey
MIAA05

MIAA basketball 2004-2005 season
Kids

Goals and popularity factors for school kids
PaperPlanes

Paper airplanes
Pendulum

Pendulum data
AirlineArrival

Airline On-Time Arrival Data
Fumbles

NCAA football fumbles
GPA

GPA, ACT, and SAT scores
MLB2004

Major League Baseball 2004 team data
Ice

Cooling muscles with ice
Inflation

Inflation data
Noise

Noise
Pallets

Pallet repair data
Spheres

Measuring spheres
BallDrop

Ball dropping data
Step

Stepping experiment
givenOrder

Create ordered factor with order inferred from order given
golfballs

Golf ball numbers
tdf

Compute degrees of freedom for a 2-sample t-test
MathNoise

Test performance and noise
PetStress

Pets and stress
Pigs

Pass the Pigs
RubberBand

Rubber band launching -- unfinished documentation
SSplot

Sum of Squares Plots
Traffic

New England traffic fatalities (1951-1959)
Trebuchet

Trebuchet data
rgolfballs

Simulated golf ball data
Stereogram

Stereogram fusion
Students

Standardized test scores and GPAs
col.fastR

Lattice Theme
col.perc

Row and Column Percentages
vaov

ANOVA vectors
undocumented

Undocumented functions
snippet

Display or execute a snippet of R code
wilson.ci

Confidence Intervals for Proportions
Pitching2005

Major League Baseball 2005 pitching
Poison

Poison data
TasteTest

Taste test data
TireWear

Estimating tire wear
fastR-package

Foundations and Applications of Statistics
geolm

Geometric representation of linear model
nlmax

Nonlinear maximization and minimization
plot.maxLik2

plot method for augment maxLik objects