2.2a

library(UsingR)
## Loading required package: MASS
## Loading required package: HistData
## Loading required package: Hmisc
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
## 
##     format.pval, units
library(MASS)
hist(brightness, freq=FALSE)
lines(density(brightness), col="red")

2.2b

boxplot(brightness)

boxplot(brightness, outline=FALSE)

Outliers=boxplot(brightness)$out

orden=sort(Outliers)
orden[2]
## [1] 2.28

2.3

table(UScereal$mfr,UScereal$shelf)
##    
##      1  2  3
##   G  6  7  9
##   K  4  7 10
##   N  2  0  1
##   P  2  1  6
##   Q  0  3  2
##   R  4  0  1