tfl

Generates clinical TFL tables, figures, and listings code using tern and rtables from ADaM datasets.

13|6|Updated Aug 9, 2026
One-click install
npx skills add https://github.com/kaipingyang/CDISC_training --skill tfl-kaipingyang
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tfl
Source: https://github.com/kaipingyang/CDISC_training/tree/main/.claude/skills/tfl
Command: npx skills add https://github.com/kaipingyang/CDISC_training --skill tfl-kaipingyang

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires rtables, tern, rlistings, ggplot2, dplyr, pharmaverseadam, rtables.officer, flextable, officer, and includes references (resource) components.

What problem does it solve? Clinical data staff without R programming experience struggle to produce the Tables, Figures, and Listings (TFL/TLG) required for clinical study reports. This Skill turns natural-language descriptions of a target output into runnable R code built on the pharmaverse TLG stack (tern + rtables), using CDISC ADaM datasets as input. ## Core Features & Use Cases - Table generation: Produces demographic tables, adverse event summary tables (with correct alt_counts_df denominators from ADSL), toxicity-grade tables, and lab shift tables via tern functions like analyze_vars and count_occurrences. - Figure generation: Creates Kaplan-Meier survival curves with g_km, mean line plots with g_lineplot, and waterfall plots, exported via ggsave as ggplot objects. - Reference library: Ships references covering the layout-vs-data mental model, a five-step table skeleton, a tern function cheat sheet, Word (docx) export via rtables.officer/flextable, and navigation to the official TLG Catalog. - Use Case: A clinical data manager asks for an AE summary table by system organ class and preferred term; the Skill generates code that filters ADAE, aligns factor levels with ADSL, builds the layout, and passes alt_counts_df = adsl so percentages use the correct denominator. ## Quick Start Ask the assistant to generate a demographic characteristics table by treatment arm from the pharmaverseadam ADSL dataset using tern and rtables.

Frequently Asked Questions about tfl

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a demographic table in R with tern and rtables?

Filter ADSL to your analysis population, factor the grouping variables, and apply df_explicit_na. Then build a layout with basic_table, split_cols_by on the treatment arm, and analyze_vars for the summary variables, and call build_table with the ADSL data.

How do I generate a Kaplan-Meier survival curve in R?

Use tern's g_km function with an ADTTE dataset filtered to a PARAMCD such as OS. Map AVAL to time, ARM to the grouping variable, and derive is_event as CNSR == 0, then export the returned ggplot object with ggsave.

Why are my AE table percentages wrong in rtables?

The denominator is wrong because ADAE only contains subjects who experienced an event. Pass alt_counts_df = adsl to build_table so percentages use the total subjects per arm from ADSL instead of the ADAE subject count.

What is the difference between tern and rtables?

rtables is the low-level layout engine providing basic_table, split_cols_by, and build_table. tern is a clinical layer on top that supplies prebuilt analysis functions like analyze_vars, count_occurrences, and g_km, so most users mainly call tern.

Can I export rtables output to Word documents?

Yes, but export_as_docx was removed in rtables 0.6.x. Convert the table with rtables.officer::tt_to_flextable, style it with flextable, and insert it into an officer document saved via print with a target file path.

Can I practice TFL generation without real clinical data?

Yes. Install the pharmaverseadam package and use its built-in datasets such as adsl, adae, and adtte_onco from the CDISCPILOT01 study. All templates run against these public test datasets without any real patient data.