黄利东
22/04/2021
-Excel是最常用的数据处理工具
-Excel的功能非常强大
-R做数据处理离不开Excel
-学好Excel对R有很大的帮助
数据集选取于ggplot2包下的diamonds数据
## # A tibble: 10 x 10
## carat cut color clarity depth table price x y z
## <dbl> <ord> <ord> <ord> <dbl> <dbl> <int> <dbl> <dbl> <dbl>
## 1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43
## 2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31
## 3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31
## 4 0.290 Premium I VS2 62.4 58 334 4.2 4.23 2.63
## 5 0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75
## 6 0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48
## 7 0.24 Very Good I VVS1 62.3 57 336 3.95 3.98 2.47
## 8 0.26 Very Good H SI1 61.9 55 337 4.07 4.11 2.53
## 9 0.22 Fair E VS2 65.1 61 337 3.87 3.78 2.49
## 10 0.23 Very Good H VS1 59.4 61 338 4 4.05 2.39
此数据集包含近54,000颗钻石的价格和其他属性的数据集
-price in US dollars ($326–$18,823)
-carat weight of the diamond (0.2–5.01)
-cut quality of the cut (Fair, Good, Very Good, Premium, Ideal)
-color diamond colour, from J (worst) to D (best)
-clarity a measurement of how clear the diamond is (I1 (worst), SI2, SI1, VS2, VS1, VVS2, VVS1, IF (best))
-x length in mm (0–10.74)
-y width in mm (0–58.9)
-z depth in mm (0–31.8)
-depth total depth percentage = z / mean(x, y) = 2 * z / (x + y) (43–79)
-table width of top of diamond relative to widest point (43–95)
图1:钻石钻石!!!
请用微信扫描二维码下载数据
图2:微信扫码下载钻石数据
简单统计函数使用
-请计算钻石的平均carat数,并计算其他列的平均值(向右拉动填充柄,看看哪些数据不能计算,并思考为什?)
-计算总共收录了多少颗钻石(count函数和countA函数)
-标准偏差怎么求(stdev函数)
-其他函数,自行学习,按需所学
-冻结窗格
图3:冻结窗口示意
-快速到底/到头
利用快捷键。Ctrl+end; 把鼠标移动到单元格【下边框】上,鼠标变成十字箭头性状时,双击
-快速填充
拖拽填充柄
图4:填充柄
-筛选
-排序
-不同切割技术下,钻石的平均价格是?
-不同颜色下,钻石的平均价格是?
-不同切割技术,不同颜色下,钻石大小怎么样?
可以利用筛选功能进行计算
图5:筛选和排序的操作
类似操作如下