This repository has been archived by the owner on Jun 9, 2020. It is now read-only.
forked from kabacoff/RiA2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ch21 Creating a package.R
42 lines (36 loc) · 1.77 KB
/
Ch21 Creating a package.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#-------------------------------------------------------------------#
# R in Action (2nd ed): Chapter 21 #
# Creating a package #
# requires packages roxygen2 #
# install.packages("roxygen2", depend=TRUE) #
# Windows users will need #
# rtools.exe (http://cran.r-project.org/bin/windows/Rtools/) #
# MikTeX (http://miktex.org/) #
# Mac users will need #
# MacTeX (http://www.tug.org/mactex/) #
# Linux users should just need the roxygen2 package #
#-------------------------------------------------------------------#
# Install the npar package
pkg <- "npar_1.0.tar.gz"
loc <- "http://www.statmethods.net/RiA"
url <- paste(loc, pkg, sep="/")
download.file(url, pkg)
install.packages(pkg, repos=NULL, type="source")
# Explore the life dataset
library(npar)
hist(life$hlef, xlab="Healthy Life Expectacy (years) at Age 65",
main="Distribution of Healthy Life Expectancy for Women",
col="grey", breaks=10)
dotchart(hlef ~ region, life, col="darkgrey", vertical=TRUE,
xlab="US Region",
ylab="Healthy Life Expectancy (years) at Age 65",
main="Distribution of HLE Estimates by Region")
# Listing 21.1 - Comparison of HLE estimates with the npar package
results <- oneway(hlef ~ region, life)
summary(results)
plot(results, col="lightblue", main="Multiple Comparisons",
xlab="US Region",
ylab="Healthy Life Expectancy (years) at Age 65")
# source code for the package can be
# downloaded from
http://www.statmethods.net/RiA/nparFiles.zip