Package: nalanda 0.0.2.0

Rémi Thériault

nalanda: R Toolbox to answer the question: Do books really change lives?

Provides tools and utilities for analyzing research data related to books, reading, and prosocial behavior. Named after the historic Nalanda Mahavihara, a center of learning and scholarly collaboration in ancient India.

Authors:Rémi Thériault [aut, cre]

nalanda_0.0.2.0.tar.gz
nalanda_0.0.2.0.zip(r-4.7)nalanda_0.0.2.0.zip(r-4.6)nalanda_0.0.2.0.zip(r-4.5)
nalanda_0.0.2.0.tgz(r-4.6-any)nalanda_0.0.2.0.tgz(r-4.5-any)
nalanda_0.0.2.0.tar.gz(r-4.7-any)nalanda_0.0.2.0.tar.gz(r-4.6-any)
nalanda_0.0.2.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
nalanda/json (API)

# Install 'nalanda' in R:
install.packages('nalanda', repos = c('https://centerconflictcooperation.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/centerconflictcooperation/nalanda/issues

Pkgdown/docs site:https://centerconflictcooperation.github.io

Datasets:

On CRAN:

Conda:

4.54 score 50 exports 58 dependencies

Last updated from:8146a43c78. Checks:7 ERROR, 2 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64ERROR181
source / vignettesOK248
linux-release-x86_64ERROR166
macos-release-arm64ERROR130
macos-oldrel-arm64ERROR154
windows-develERROR110
windows-releaseERROR117
windows-oldrelERROR115
wasm-releaseOK155

Exports:aggregate_simulationsbuild_simulate_treatment_promptcombine_book_filescombine_split_chapter_filescompute_run_ai_metricscompute_run_ai_metrics_cumulativecompute_run_ai_metrics_one_turnevaluate_text_analysisextract_pdf_text_with_llmfix_text_fileinterpolate_spotify_audiobook_durationlist_book_chaptersmake_annotation_promptmake_baseline_promptmake_post_promptmake_treatment_promptmodel_agreementmodel_agreement_sensitivitymodel_pairwise_cormodel_rank_consistencynalandapairwise_for_levelplot_chapter_scores_facetedplot_chapter_trajectoriesplot_chapters_over_timeplot_chapters_over_time_one_turnplot_forest_booksplot_model_agreementplot_top_unit_heatmapplot_top_unit_pairsplot_top_unitsprepare_forest_booksrank_weightedread_book_textsrename_chaptersrenumber_chapters_across_foldersrun_ai_cumulative_chaptersrun_ai_on_chaptersrun_ai_on_chapters_one_turnrun_text_analysissave_forest_plotsimulate_treatmentsplit_book_section_by_headingssummarize_chapter_scoressummarize_identity_adherencesummarize_identity_match_ratessummarize_model_correlationssummarize_simulation_stabilitysummarize_top_unitssummarize_treatment_results

Dependencies:abindaskpassbackportsbitbit64checkmateclicliprcorocpp11crayoncurldplyrellmerfarverfastmapforestplotgenericsggplot2gluegtablehmshttr2isobandjsonlitelabelinglaterlifecyclemagrittropensslotelpillarpkgconfigprettyunitsprogresspromisespurrrR6rappdirsRColorBrewerRcppreadrrempsycrlangS7scalesstringistringrsystibbletidyrtidyselecttzdbutf8vctrsviridisLitevroomwithr

Post-Only Identity Treatments with simulate_treatment()
Purpose | 1. Set package options | 2. Define the treatment text and prompt | 3. Preview the prompt before running | 4. Run the post-only simulation | 5. Inspect the raw output | 6. Summarize by identity | 7. Compare another group to Americans | When to use which function

Last update: 2026-04-06
Started: 2026-03-18

Psychological Text Analysis with nalanda
Purpose | 1. Set package options | 2. Create a small text dataset | 3. Build the prompt | 4. Run the analysis | 5. Inspect the output | 6. Evaluate GPT against human labels | 7. Likert-style sentiment or emotion | 8. Repeated runs for reliability | 9. When to use this workflow | Reference

Last update: 2026-04-06
Started: 2026-03-25

Getting Started with Ellmer and Nalanda
Step 1: Verify your connection with ellmer | Step 2: Run a minimal nalanda workflow

Last update: 2026-03-27
Started: 2026-03-13

Roadmap for Paper-Faithful Simulation Workflows
Purpose | Current package status | What the papers add | Recommended implementation steps | Why these steps matter | Step 1: Prompt layer | Step 2: Condition-based simulation wrapper | Step 3: Descriptive summaries and calibration | Step 4: Demographic profile infrastructure | Step 5: Ensemble controls | Step 6: Cumulative chapter designs | What can be applied directly to the existing chapter workflow? | Transferable immediately | Transferable with design adaptation | Less transferable without stronger validation | Where should calibration happen? | Why not pre-adjust inside simulation functions? | Why not leave calibration entirely to user scripts? | Recommended compromise | Proposed object designs | prompt_bank | ensemble_size | demographic_profiles | Proposed next steps | References

Last update: 2026-03-17
Started: 2026-03-17

Understanding Hewitt et al. and Using Nalanda Today
Overview | What the papers did, in simple language | What the supplement adds | 1. Prompting strategy matters | 2. Ensemble prompting matters | 3. Demographic conditioning is part of the method | 4. Absolute effect sizes need caution | Recommended take-aways for users | How this relates to nalanda | A concrete way to use nalanda today | Scenario 1: Pre/post chapter simulations | Scenario 2: Post-only simulations | Scenario 3: Control-versus-treatment chapter comparisons | What users should currently do themselves | 1. Build or manage a prompt bank manually | 2. Run ensembles manually | 3. Manage demographic profiles manually | 4. Estimate between-condition contrasts downstream | 5. Apply effect calibration explicitly | How to think about the 0.56 factor | When it is reasonable to use it | When to be cautious | Best current practice | A simple recommended workflow for users | Minimal workflow | Better workflow | What nalanda may support later | Final practical advice | References

Last update: 2026-03-17
Started: 2026-03-17

Readme and manuals

Help Manual

Help pageTopics
Aggregate simulation runsaggregate_simulations
Combine chapter text files into one numbered file per bookcombine_book_files
Combine split chapter chunk filescombine_split_chapter_files
Compute derived pre/post effect metrics from raw turn-level outputcompute_run_ai_metrics
Compute cumulative chapter metrics against the original baselinecompute_run_ai_metrics_cumulative
Compute one-turn ingroup/outgroup metrics from raw outputcompute_run_ai_metrics_one_turn
Evaluate text-analysis outputs against reference labelsevaluate_text_analysis
Extract text from a PDF with a multimodal LLMextract_pdf_text_with_llm
Fix text file encoding and normalize punctuation/whitespacefix_text_file
Interpolate Spotify audiobook duration from text sizeinterpolate_spotify_audiobook_duration
List book chapter files inside a books directorylist_book_chapters
Build a numeric-response prompt for text analysismake_annotation_prompt
Build the baseline (Turn 1) promptmake_baseline_prompt
Build the post-intervention (Turn 2) promptmake_post_prompt
Build a concrete prompt for 'simulate_treatment()'build_simulate_treatment_prompt make_treatment_prompt
Compute inter-model agreementmodel_agreement
Summarize model agreement across analysis levelsmodel_agreement_sensitivity
Pairwise model correlationsmodel_pairwise_cor
Compare model-derived rankingsmodel_rank_consistency
A Random Historical Fact About Nalanda Universitynalanda
Pairwise model correlations at a chosen analysis levelpairwise_for_level
Faceted plot of chapter scoresplot_chapter_scores_faceted
Plot chapter trajectories by bookplot_chapter_trajectories
Plot chapters over time (multi-timepoint means)plot_chapters_over_time
Plot chapter trajectories for one-turn simulationsplot_chapters_over_time_one_turn
Create a forest plot of book-level polarization reduction effectsplot_forest_books
Plot inter-model agreementplot_model_agreement
Plot model-by-unit rank heatmapplot_top_unit_heatmap
Plot paired subgroup ranks for top unitsplot_top_unit_pairs
Plot units that rank consistently high across modelsplot_top_units
Prepare book-level data for forest plottingprepare_forest_books
Rank rows using a weighted rubricrank_weighted
Read book chapters into a nested listread_book_texts
Rename chapter text files in a folder to a sequential orderrename_chapters
Renumber chapter files across ordered foldersrenumber_chapters_across_folders
Run AI model on books with cumulative chapter contextrun_ai_cumulative_chapters
Run AI model on book chapters and collect structured responsesrun_ai_on_chapters
Run AI model on book chapters with a single prompt per simulationrun_ai_on_chapters_one_turn
Run row-wise text analysis with a prompt templaterun_text_analysis
Save a forest plot to PNG and PDF formatssave_forest_plot
Simulate a generic multi-turn treatment workflowsimulate_treatment
Split a book section into chapter files using known headingssplit_book_section_by_headings
Summarize simulated chapter scoressummarize_chapter_scores
Summarize whether the model adopts the requested identitysummarize_identity_adherence
Summarize identity match rates by modelsummarize_identity_match_rates
Summarize pairwise model correlationssummarize_model_correlations
Summarize simulation stability across chapterssummarize_simulation_stability
Summarize units that rank consistently high across modelssummarize_top_units
Summarize generic treatment resultssummarize_treatment_results
Toy raw turn-level AI simulation outputtoy_run_ai_turns
Toy simulated chapter resultstoy_sim_results