## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>") ## ----------------------------------------------------------------------------- library(LISTC) set.seed(2026) n <- 3000 demo <- data.frame( student_id = sprintf("S%05d", seq_len(n)), region = sample(c("东部", "中部", "西部"), n, TRUE, c(.4, .35, .25)), gender = sample(c("男", "女"), n, TRUE), w_final = runif(n, 0.5, 2), th_math = rnorm(n), se_math = runif(n, 0.25, 0.45), raw_total = rpois(n, 40) ) ## ----------------------------------------------------------------------------- x <- lst_data(demo, id = student_id, group = c(region, gender), weight = w_final, theta = c(math = th_math), theta_se = c(math = se_math), score = raw_total ) x ## ----------------------------------------------------------------------------- lv <- c(待提高 = -Inf, 合格 = -0.5, 良好 = 0.5, 优秀 = 1.2) tab <- lst_table(x, rows = region, cols = gender, values = list( 平均能力 = st_mean(math), 优秀率 = st_prop_above(math, cutoff = 1.2, method = "prob"), 等级 = st_level_prop(math, breaks = lv, method = "prob"), 人数 = st_count() ), margins = TRUE ) tab ## ----------------------------------------------------------------------------- head(as_long(tab)) ## ----------------------------------------------------------------------------- lst_table(x, rows = region, values = list( 优秀率_latent = st_prop_above(math, cutoff = 1.2, method = "prob", correction = "latent") )) ## ----eval = FALSE------------------------------------------------------------- # lst_to_excel(tab, "results.xlsx", overwrite = TRUE) # 中文样式 + 结论 sheet # lst_to_json(tab) # 给 AI agent / 二次分析 # lst_interpret(tab) # 规则化自动解读文字 ## ----eval = FALSE------------------------------------------------------------- # lst_config_template("LISTC配置.xlsx") # 生成模板,按"说明"sheet 填写 # lst_run("LISTC配置.xlsx") # 一键出全部结果 ## ----eval = FALSE------------------------------------------------------------- # pf <- read_winsteps_pfile("person.pfile") # 或 read_conquest_person() # x <- lst_data(demo, id = student_id, group = region) |> # lst_join_person(pf, dim = "math")