Folioevanzhou.org
← 返回 Tessera
原样32 行 × 12 列2 KB无缺失数据 2026-08-11

mtcars

Fuel consumption and ten design and performance measures for 32 car models from 1974.

One row represents one car model.

R package · 收录于 2026-08-11

下载 CSV · 2 KB
数据预览前 6 行
modelmpgcyldisphpdratwtqsecvsamgearcarb
Mazda RX421.06160.01103.92.6216.50144
Mazda RX4 Wag21.06160.01103.92.8817.00144
Datsun 71022.84108.0933.852.3218.61141
Hornet 4 Drive21.46258.01103.083.2119.41031
Hornet Sportabout18.78360.01753.153.4417.00032
Valiant18.16225.01052.763.4620.21031
变量12 列
字符型1整数6双精度5
类型
#变量类型缺失统计
1modelCar model name, kept from the original row names.字符型—不同值 32Mazda RX4 · Mazda RX4 Wag · Datsun 710 · Hornet 4 Drive · Hornet Sportabout · Valiant · Duster 360 · Merc 240D
2mpgkeyMiles per US gallon.双精度—min 10.4q1 —中位 19.2均值 20.1q3 —max 33.9
3cylNumber of cylinders.整数—min 4q1 —中位 6均值 6.19q3 —max 8
4dispDisplacement in cubic inches.双精度—min 71.1q1 —中位 196.3均值 230.7q3 —max 472.0
5hpGross horsepower.整数—min 52.0q1 —中位 123.0均值 146.7q3 —max 335.0
6dratRear axle ratio.双精度—min 2.76q1 —中位 3.7均值 3.6q3 —max 4.93
7wtWeight in thousands of pounds.双精度—min 1.51q1 —中位 3.33均值 3.22q3 —max 5.42
8qsecQuarter-mile time in seconds.双精度—min 14.5q1 —中位 17.7均值 17.8q3 —max 22.9
9vs0 is a V engine. 1 is a straight engine.整数—min 0q1 —中位 0均值 0.406q3 —max 1
10am0 is automatic. 1 is manual.整数—min 0q1 —中位 0均值 0.406q3 —max 1
11gearNumber of forward gears.整数—min 3q1 —中位 4均值 3.69q3 —max 5
12carbNumber of carburettors.整数—min 1q1 —中位 2均值 2.81q3 —max 8
载入已写好列类型
library(readr)

mtcars <- read_csv(
  "https://assets.evanzhou.org/tessera/csv/mtcars.csv",
  col_types = cols(
    model = col_character(),
    mpg   = col_double(),
    cyl   = col_integer(),
    disp  = col_double(),
    hp    = col_integer(),
    drat  = col_double(),
    wt    = col_double(),
    qsec  = col_double(),
    vs    = col_integer(),
    am    = col_integer(),
    gear  = col_integer(),
    carb  = col_integer()
  )
)
URLhttps://assets.evanzhou.org/tessera/csv/mtcars.csv

Source

R 自带的 datasets::mtcars,来自 1974 年美国《Motor Trend》杂志。32 款汽车包含燃油效率、气缸数、排量、马力、重量和变速器等 11 个数值变量。

原数据把车型名存在行名里;这里导出时将其保留为 model 列,其余变量和值不变。完整变量定义见 R 官方文档。

Use cases

  • 相关性热图:同时比较多项性能指标的正负相关结构
  • 散点矩阵:回到具体变量对检查形态与离群点
  • 平行坐标:比较不同车型的多指标轮廓
  • 聚类热图:按整体性能结构重排车型或变量
生成脚本R · 21 行
# 产物写到 ../csv/mtcars.csv —— 脚本和 CSV 是 content/tessera/data/ 下固定的兄弟目录,
# 所以按脚本自身定位,不依赖你在哪个目录敲这条命令。csv/ 不进仓库(见 .gitignore)。
#
# Rscript 时路径在 --file= 里,source() 时在 sys.frame()$ofile 里,两种都要认:
# 只取其中一种的话,另一种跑法会静默地把 CSV 写到当前目录去。
script_dir <- local({
  arg <- grep("^--file=", commandArgs(trailingOnly = FALSE), value = TRUE)
  path <- if (length(arg)) sub("^--file=", "", arg[[1L]]) else sys.frame(1)$ofile
  dirname(normalizePath(path, mustWork = TRUE))
})
out_csv <- file.path(script_dir, "..", "csv", "mtcars.csv")
dir.create(dirname(out_csv), recursive = TRUE, showWarnings = FALSE)

d <- cbind(model = rownames(datasets::mtcars), datasets::mtcars)

write.csv(
  d,
  out_csv,
  row.names = FALSE,
  quote = FALSE
)

表中统计由 scripts/profile_dataset.py 于 2026-08-11 数出。