EVOLUTION-MANAGER
Edit File: cars.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Speed and Stopping Distances of Cars</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for cars {datasets}"><tr><td>cars {datasets}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Speed and Stopping Distances of Cars</h2> <h3>Description</h3> <p>The data give the speed of cars and the distances taken to stop. Note that the data were recorded in the 1920s. </p> <h3>Usage</h3> <pre>cars</pre> <h3>Format</h3> <p>A data frame with 50 observations on 2 variables. </p> <table summary="Rd table"> <tr> <td style="text-align: right;"> [,1] </td><td style="text-align: left;"> speed </td><td style="text-align: left;"> numeric </td><td style="text-align: left;"> Speed (mph)</td> </tr> <tr> <td style="text-align: right;"> [,2] </td><td style="text-align: left;"> dist </td><td style="text-align: left;"> numeric </td><td style="text-align: left;"> Stopping distance (ft) </td> </tr> </table> <h3>Source</h3> <p>Ezekiel, M. (1930) <em>Methods of Correlation Analysis</em>. Wiley. </p> <h3>References</h3> <p>McNeil, D. R. (1977) <em>Interactive Data Analysis</em>. Wiley. </p> <h3>Examples</h3> <pre> require(stats); require(graphics) plot(cars, xlab = "Speed (mph)", ylab = "Stopping distance (ft)", las = 1) lines(lowess(cars$speed, cars$dist, f = 2/3, iter = 3), col = "red") title(main = "cars data") plot(cars, xlab = "Speed (mph)", ylab = "Stopping distance (ft)", las = 1, log = "xy") title(main = "cars data (logarithmic scales)") lines(lowess(cars$speed, cars$dist, f = 2/3, iter = 3), col = "red") summary(fm1 <- lm(log(dist) ~ log(speed), data = cars)) opar <- par(mfrow = c(2, 2), oma = c(0, 0, 1.1, 0), mar = c(4.1, 4.1, 2.1, 1.1)) plot(fm1) par(opar) ## An example of polynomial regression plot(cars, xlab = "Speed (mph)", ylab = "Stopping distance (ft)", las = 1, xlim = c(0, 25)) d <- seq(0, 25, length.out = 200) for(degree in 1:4) { fm <- lm(dist ~ poly(speed, degree), data = cars) assign(paste("cars", degree, sep = "."), fm) lines(d, predict(fm, data.frame(speed = d)), col = degree) } anova(cars.1, cars.2, cars.3, cars.4) </pre> <hr /><div style="text-align: center;">[Package <em>datasets</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>