@Roland , , , ( ), , R. SO @SvenHohenstein: R , as.numeric, , , , - "" (, " " ) LHS- . , , 1000 cut2-5 cut1. "value" cut == 1 "(Intercept)". :
> cbind( levels(diamonds$cut), c(coef(model.cut)[grep('Intercept|cut', names(coef(model.cut)))] ))
[,1] [,2]
(Intercept) "Fair" "-5189.46034442502"
cut2 "Good" "909.432743872746"
cut3 "Very Good" "1129.51839934007"
cut4 "Premium" "1156.98898349819"
cut5 "Ideal" "1264.12800574865"
, ( ):
> with(diamonds, tapply(price, cut, mean))
Fair Good Very Good Premium Ideal
4358.758 3928.864 3981.760 4584.258 3457.542
, carat:
> with(diamonds, tapply(price, list(cut, cut2(carat, g=5) ), mean))
[0.20,0.36) [0.36,0.54) [0.54,0.91) [0.91,1.14) [1.14,5.01]
Fair 802.4528 1193.162 2336.543 4001.972 8682.351
Good 574.7482 1101.406 2701.412 4872.072 9788.294
Very Good 597.9258 1151.537 2727.251 5464.223 10158.057
Premium 717.1096 1149.550 2537.446 5214.787 10131.999
Ideal 739.8972 1254.229 2624.180 6050.358 10317.725
, ... ? , 800 "" ?
contrasts(diamonds$cut, how.many=1) <- poly(1:5)
> model.cut2 <- lm(price ~ carat+cut, diamonds)
> model.cut2
Call:
lm(formula = price ~ carat + cut, data = diamonds)
Coefficients:
(Intercept) carat cut1
-2555.1 7838.5 815.8
> contrasts(diamonds$cut)
1
Fair -0.6324555
Good -0.3162278
Very Good 0.0000000
Premium 0.3162278
Ideal 0.6324555
carat constant Fair versus Ideal (-0.6324555 -0.6324555) * 815.8 1031,91 ( ... )
, , , , , "". . poly -, "" . , , R poly(). 1, 0.