Folioevanzhou.org
← Back to Tessera
Canonical32 rows × 12 cols2 KBNo missingSnapshot 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 · added 2026-08-11

Download CSV · 2 KB
PreviewFirst 6 rows
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
Variables12 cols
Character1Integer6Double5
Type
#VariableTypeMissingSummary
1modelCar model name, kept from the original row names.Character—unique 32Mazda RX4 · Mazda RX4 Wag · Datsun 710 · Hornet 4 Drive · Hornet Sportabout · Valiant · Duster 360 · Merc 240D
2mpgkeyMiles per US gallon.Double—min 10.4q1 —median 19.2mean 20.1q3 —max 33.9
3cylNumber of cylinders.Integer—min 4q1 —median 6mean 6.19q3 —max 8
4dispDisplacement in cubic inches.Double—min 71.1q1 —median 196.3mean 230.7q3 —max 472.0
5hpGross horsepower.Integer—min 52.0q1 —median 123.0mean 146.7q3 —max 335.0
6dratRear axle ratio.Double—min 2.76q1 —median 3.7mean 3.6q3 —max 4.93
7wtWeight in thousands of pounds.Double—min 1.51q1 —median 3.33mean 3.22q3 —max 5.42
8qsecQuarter-mile time in seconds.Double—min 14.5q1 —median 17.7mean 17.8q3 —max 22.9
9vs0 is a V engine. 1 is a straight engine.Integer—min 0q1 —median 0mean 0.406q3 —max 1
10am0 is automatic. 1 is manual.Integer—min 0q1 —median 0mean 0.406q3 —max 1
11gearNumber of forward gears.Integer—min 3q1 —median 4mean 3.69q3 —max 5
12carbNumber of carburettors.Integer—min 1q1 —median 2mean 2.81q3 —max 8
Loadcolumn types set
r
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

  • 相关性热图:同时比较多项性能指标的正负相关结构
  • 散点矩阵:回到具体变量对检查形态与离群点
  • 平行坐标:比较不同车型的多指标轮廓
  • 聚类热图:按整体性能结构重排车型或变量
Build scriptR · 21 lines
r
# 产物写到 ../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
)

Stats computed by scripts/profile_dataset.py on 2026-08-11.