
本文共 3092 字,大约阅读时间需要 10 分钟。
2.3 ���������������������
���������������������������������������������������������������������R������������������������������������������������������������������������������������������������������������������������������������������������������
���������������
���R���������read.csv()
������������������������������������������str()
������������������������������������������������������������������������������������������������������������������������������������������������������������������������
## ���������������������������usedcars <- read.csv("usedcars.csv", stringsAsFactors = FALSE)str(usedcars)
������������������������������������������������������������������������������������������������������������������������������������������
���������������������
������������������������summary()
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
���������
## ���������������������summary(usedcars$year)summary(usedcars[c("price", "mileage")])
���������������������
- ���������������������������������������������������������������������������������������
- ���������������������������������������������������������������������������������������
���������������������
- ������������������������������������������������������������
- ���������������IQR������������������������������������Q3 - Q1���������������������������������������������������
���������
## ������������������������������mean(c(36000, 44000, 56000))median(c(36000, 44000, 56000))
������������������
���������������������������������������������������������������������������table()
���prop.table()
���������������������������������������������������������������������������
##���������������������������table(usedcars$year)table(usedcars$model)table(usedcars$color)## ���������������������model_table <- table(usedcars$model)model_pct <- prop.table(model_table)round(model_pct, digits = 1)color_table <- table(usedcars$color)color_pct <- prop.table(color_table) * 100round(color_pct, digits = 1)
������������������������
���������������������������������������������������������������������������������������������������������������
## ���������������������������������������plot(x = usedcars$mileage, y = usedcars$price, main = "Scatterplot of Price vs. Mileage", xlab = "Used Car Odometer (mi.)", ylab = "Used Car Price ($)")
���������������������������������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������������������������������������������������������
## ���������������������������������������boxplot(usedcars$price, main="Boxplot of Used Car Prices", ylab="Price ($)")boxplot(usedcars$mileage, main="Boxplot of Used Car Mileage", ylab="Odometer (mi.)")hist(usedcars$price, main="Histogram of Used Car Prices", xlab="Price ($)")hist(usedcars$mileage, main="Histogram of Used Car Mileage", xlab="Odometer (mi.)")
发表评论
最新留言
关于作者
