Folioevanzhou.org
← Back to Tessera
Adapted228 rows × 6 cols5 KB1 cols with missingSnapshot 2026-08-13

lung_survival

Follow-up time and outcome for 228 advanced lung cancer patients, with sex, age and ECOG performance score.

One row represents one patient.

R package · added 2026-08-13

Download CSV · 5 KB
PreviewFirst 6 rows
idtime_dayseventsexage_yearsph_ecog
13061male741
24551male680
31,0100male560
42101male571
58831male600
61,0220male741
Variables6 cols
Character1Integer5
Type
#VariableTypeMissingSummary
1idStable row number added by Tessera.Integer—min 1q1 —median 114.5mean 114.5q3 —max 228.0
2time_dayskeyFollow-up time in days.Integer—min 5q1 —median 255.5mean 305.2q3 —max 1,022
3event0 is censored. 1 is death.Integer—min 0q1 —median 1mean 0.724q3 —max 1
4sexSex of the patient.Character—unique 2male · female
5age_yearsAge at enrolment, in years.Integer—min 39.0q1 —median 63.0mean 62.4q3 —max 82.0
6ph_ecogECOG performance score rated by the physician. 0 is fully active, higher is worse.Integer1min 0q1 —median 1mean 0.952q3 —max 3
Loadcolumn types set
r
library(readr)

lung_survival <- read_csv(
  "https://assets.evanzhou.org/tessera/csv/lung_survival.csv",
  col_types = cols(
    id        = col_integer(),
    time_days = col_integer(),
    event     = col_integer(),
    sex       = col_character(),
    age_years = col_integer(),
    ph_ecog   = col_integer()
  )
)
URLhttps://assets.evanzhou.org/tessera/csv/lung_survival.csv

Source

R survival 包自带的 lung 数据,记录 North Central Cancer Treatment Group 的 228 例晚期肺癌患者。Tessera 保留绘制生存曲线所需的随访时间、结局、性别、年龄和 ECOG 体能状态,并增加稳定的行号 id。

原数据的隐式编码容易误用:status 是 1 = 删失、2 = 死亡,sex 是 1 = male、2 = female。这里已经明确转换为 event = 0/1 和有名字的 sex;转换过程完整保留在生成脚本中。

Use cases

  • Kaplan–Meier 曲线:比较两组随访期间的生存概率,并配合风险表判断尾部稳定性
  • 累计风险曲线:从风险累积的角度查看两组差异
  • 固定时间点生存率:报告 1 年、2 年等预设时间点的估计值和置信区间
  • Cox 模型:练习风险比估计,并用年龄或 ECOG 评分作调整
Build scriptR · 31 lines
r
# 产物写到 ../csv/lung_survival.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", "lung_survival.csv")
dir.create(dirname(out_csv), recursive = TRUE, showWarnings = FALSE)

lung <- survival::lung

# survival::lung uses 1 = censored / 2 = death and 1 = male / 2 = female.
# Freeze those implicit codes into explicit analysis-ready columns for Tessera.
lung_survival <- data.frame(
  id = seq_len(nrow(lung)),
  time_days = lung$time,
  event = ifelse(lung$status == 2L, 1L, 0L),
  sex = ifelse(lung$sex == 1L, "male", "female"),
  age_years = lung$age,
  ph_ecog = lung$ph.ecog
)

write.csv(
  lung_survival,
  out_csv,
  row.names = FALSE
)

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