无论是R 的base 包,还是像tidyverse 套件中的数据处理相关的R 包,都提供了很多数据集,便于我们的实战。
其实查看它们也很方便:
data() 就搞定了,其会返回一个列表,其中result 元素中包含了这些数据集信息的数据框:
> colnames(data()$results)[1] "Package" "LibPath" "Item" "Title" > table(data()$results[,"Package"])datasets 104
我们可以直接通过results 中的Item 中的内容使用它们:
> head(data()$results[,"Item"])[1] "AirPassengers" "BJsales" "BJsales.lead (BJsales)" "BOD" "CO2" [6] "ChickWeight" > head(CO2) Plant Type Treatment conc uptake1 Qn1 Quebec nonchilled 95 16.02 Qn1 Quebec nonchilled 175 30.43 Qn1 Quebec nonchilled 250 34.84 Qn1 Quebec nonchilled 350 37.25 Qn1 Quebec nonchilled 500 35.36 Qn1 Quebec nonchilled 675 39.2