data(cars)
#===> vehicle price by type <===#
par(mfrow=c(1,1))
histPlot(cars$price[cars$type=='small'], probability=TRUE, hollow=TRUE, xlim=c(0,50))
histPlot(cars$price[cars$type=='midsize'], probability=TRUE, hollow=TRUE, add=TRUE, border='red', lty=3)
histPlot(cars$price[cars$type=='large'], probability=TRUE, hollow=TRUE, add=TRUE, border='blue', lty=4)
legend('topright', lty=2:4, col=c('black', 'red', 'blue'), legend=c('small', 'midsize', 'large'))
#===> vehicle price versus weight <===#
plot(cars$weight, cars$price, col=fadeColor('magenta', '88'), pch=20, cex=2)
#===> mileage versus weight <===#
plot(cars$weight, cars$mpgCity, col=fadeColor('chocolate4', '88'), pch=20, cex=2)
temp <- c(seq(1000, 5000, 100), rev(seq(1000, 5000, 100)), 1000)
polygon(temp, 87.11 - 0.03508*temp + 0.000004432*temp^2 + 7*c(rep(-1, 41), rep(1, 41), -1), col=fadeColor('black', '22'), border=fadeColor('black', '00'))
Run the code above in your browser using DataLab