我试图在我的数据集中绘制两个参数之间的线性回归。但是我无法这样做,我收到了错误
plot.default中的错误(yh,r,xlab = l.fit,ylab =" Residuals",main = main,:formal argument" xlab"匹配多个实际 参数
这是我的代码
file <- "bank.csv"
data <- read.csv(file, header=TRUE, sep=";")
data <- data[(data$Previous_Outcome == "success") | (data$Previous_Outcome == "nonexistent"),]
data <- data[(data$Duration != "0"),]
age = data$Age
duration <- data$Duration
fit <- lm(age ~ duration)
png(filename = "AgevsDurationRegression.png", width=480, height=480, units="px")
> plot(fit, main="Age vs Call Duration Regression", xlab = "Duration in Seconds", ylab = "Age in Years")
Error in plot.default(yh, r, xlab = l.fit, ylab = "Residuals", main = main, :
formal argument "xlab" matched by multiple actual arguments
str(数据)和摘要(fit)给了我这个
summary(fit)
Call:
lm(formula = age ~ duration)
Residuals:
Min 1Q Median 3Q Max
-23.063 -8.045 -2.027 6.956 58.007
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 40.0792439 0.0752589 532.551 <2e-16 ***
duration -0.0001804 0.0002040 -0.884 0.377
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 10.28 on 36930 degrees of freedom
Multiple R-squared: 2.117e-05, Adjusted R-squared: -5.903e-06
F-statistic: 0.782 on 1 and 36930 DF, p-value: 0.3765
答案 0 :(得分:3)
这有效
var GPSMapConverter = function () {
var mapOptions = {
zoom: 3,
center: new google.maps.LatLng(57.9865525, 25.40965)
};
this.map = new google.maps.Map(document.getElementById('map'), mapOptions);
this.directionsDisplay = new google.maps.DirectionsRenderer;
this.directionsService = new google.maps.DirectionsService;
};
GPSMapConverter.prototype = {
clearRoute: function() {
if (this.directionsDisplay != null) {
this.directionsDisplay.setMap(null);
}
},
printRoute: function(coordinates) {
var directionWaypoints = $.map(coordinates, function(coord, i) {
if (i > 0 && i < coordinates.length - 1) {
return {
"location": new google.maps.LatLng(coord.lat, coord.lng),
"stopover": false
};
}
});
var request = {
origin: new google.maps.LatLng(coordinates[0].lat, coordinates[0].lng),
destination: new google.maps.LatLng(coordinates[coordinates.length - 1].lat, coordinates[coordinates.length - 1].lng),
travelMode: google.maps.TravelMode.DRIVING,
waypoints: directionWaypoints
};
this.calculateAndDisplayRoute(request);
},
calculateAndDisplayRoute: function (request) {
this.directionsDisplay.setMap(this.map);
(function(display,service) {
service.route(request, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
display.setDirections(response);
} else {
alert('Directions request failed due to ' + status);
}
});
})(this.directionsDisplay, this.directionsService);
}
};
答案 1 :(得分:0)
情节(y~x)和情节(lm(y~x))之间的差异:
plot(y~x)给出变量y Vs x的散点图。和abline(lm(y~x))在图中添加回归线。
plot(lm(y~x))提供回归模型的回归诊断图。 它为给定的回归模型生成六个诊断图。
默认情况下,会提供前三个和第五个。
按Enter键逐一查看这些图。 或者要在一个窗口中查看所有四个图,请使用以下命令。它将绘图区域划分为2 * 2网格。
par(mfrow=c(2,2))
以png格式保存任何地块:
png(file="myplot", width=400, height=350)
dev.off()
同样,你可以使用
bmp(file="myplot", width=400, height=350);
jpeg(file="myplot", width=400, height=350) or
tiff(file="myplot", width=400, height=350)
用于保存其他格式的任何绘图。