# ================ # THE CARS DATASET # ================ data(swiss); swiss dim(swiss) ?swiss # ====================================== # Summary Statistic for Infant Mortality # ====================================== x <- swiss$Infant.Mortality mean(x) median(x) sd(x) hist(x) qqplot(x) # Compute Quantiles p <- c(10, 25, 50, 75, 80, 90)/100 quantile(x, probs=p) # ========================== # EXAMPLES ON ECDF # ========================== ## Computing ECDF # --------------- y <- round(rnorm(12),1); y y[3] <- y[1]; y Fn <- ecdf(y) Fn knots(Fn) # unique values (always less than 12!) summary(Fn) summary.stepfun(Fn) ### Plotting ECDF # ------------------- par(mfrow=c(3,1), mgp=c(1.5, 0.8,0), mar= rep(5, 4)) # Plot 1 plot.ecdf(y, main="ECDF of the Data") require(graphics) # Plot 2 plot(Fn, col.hor='red', add= TRUE, main="ECDF of Data") #- plot method abline(v=knots(Fn),lty=2,col='gray70') ## Plot 3: A Luxury one plot(Fn, verticals=TRUE, col.points='blue', col.hor='red', col.vert='bisque', main="ECDF of Data")