cars(datasets)
cars()所属R语言包:datasets
Speed and Stopping Distances of Cars
汽车的速度和制动距离
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The data give the speed of cars and the distances taken to stop. Note that the data were recorded in the 1920s.
数据给汽车的速度和停止距离。请注意,在1920年录得的数据。
用法----------Usage----------
格式----------Format----------
A data frame with 50 observations on 2 variables.
与50两个变量的观测数据框。
speed
速度
dist
区
源----------Source----------
Ezekiel, M. (1930) Methods of Correlation Analysis. Wiley.
以西结书,M.(1930)相关分析的方法。威利。
参考文献----------References----------
Interactive Data Analysis. Wiley.
举例----------Examples----------
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)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|