| Line | Source code | What the line does for the analysis |
|---|
| 0001 | read_result<-function(n)read.csv(file.path(OUT,"tables",paste0(n,".csv")),check.names=FALSE) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0002 | make_slides<-function(){ | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0003 | ci<-subset(read_result("pls_bootstrap_summary"),requested==5000);getci<-function(n){r<-ci[ci$parameter==n,];paste0(fmt(r$estimate)," [",fmt(r$low),", ",fmt(r$high),"]")} | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0004 | ord<-subset(read_result("ordinal_associations"),adjustment=="background") | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0005 | pred<-read_result("prediction_metrics");best<-pred[which.min(pred$RMSE),] | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0006 | bay<-read_result("bayesian_diagnostics");cfa<-subset(read_result("cfa_fit"),partition=="validation"&model=="two_factor_three") | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0007 | aipw<-read_result("aipw_summary");spec<-read_result("specification_curve");jk<-read_result("leave_one_township_out") | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0008 | slides<-list();add<-function(title,bullets,notes,figure=NULL,minutes=1.5,backup=FALSE){slides[[length(slides)+1]]<<-list(title=title,bullets=bullets,notes=notes,figure=figure,minutes=minutes,backup=backup)} | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0009 | add("Compensation application and tolerance",c("Wild-boar conflict in Giant Panda National Park, China","Fresh analysis for Mengxi Kou","Measurement, associations, mechanisms, and robustness"),"Opening: our task is to learn what this fieldwork supports, including results that challenge the original narrative. We distinguish compensation application from payment receipt throughout. Outline the 45-minute talk and reserve 15 minutes for methodological discussion.",minutes=1) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0010 | add("The substantive question",c("Can financial compensation support coexistence?","Do applicants report different tolerance?","Which lived experiences and institutional contacts accompany that difference?"),"The policy motivation is important, but this household survey measures simultaneous reports. We can describe and adjust associations; the causal effect of a compensation programme requires additional identification. Introduce the Wildlife Tolerance Model as a conceptual starting point, not a predetermined statistical solution.") | Executes a supporting calculation, option, or output step for this module. |
| 0011 | add("Study design and retained sample",c("625 households: Baoxing 160; Qingchuan 465","Different interview periods: August 2024 vs March–April 2025","25 townships; 177 complete village keys; 49 earlier exclusions unexplained"),"County and survey timing are inseparable here. There are no repeated measurements on the same households. Unknown sampling and exclusion mechanisms limit population generalization. A missing village receives its own grouping key, not an invented location.") | Executes a supporting calculation, option, or output step for this module. |
| 0012 | add("Application is not verified payment",c("CE0 asks whether the respondent applied","277 applicants; 348 non-applicants","Receipt, timing, and eligibility are not independently established"),"The original wording matters: never label CE0 as random policy exposure or guaranteed compensation receipt. Selection into applying can reflect losses, reporting access, and attitudes. Applicants are not automatically comparable to non-applicants.") | Executes a supporting calculation, option, or output step for this module. |
| 0013 | add("Application differs by county",c("County adjustment is essential context, not causal identification."),"Explain the 74% versus 34% application rates. Geographic composition can change pooled comparisons. This motivates county fixed effects and township clustering, not standard errors clustered on only two counties.","application_by_county") | Executes a supporting calculation, option, or output step for this module. |
| 0014 | add("Four questions, four dimensions",c("Non-lethal management; population control; safety; accepting damage"),"Read the substantive meaning of each item. Tol2 and Tol3 are already reversed, confirmed by Mengxi and raw responses. Higher Tol3 means less safety concern. A common positive orientation does not establish one underlying factor.","tolerance_distributions",minutes=2) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0015 | add("A traceable data rebuild",c("Preserve the workbook; record every derived change","Restore raw nonresponse and missing-word zeros","Rebuild institutional counts; flag unresolved percentages and units"),"Clarify that data cleaning is evidence-based rather than selected for favorable results. Percentages over 100% remain unresolved and receive sensitivity analysis. Non-applicants have structurally undefined payment satisfaction. Prevention non-use is not poor effectiveness.",minutes=2) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0016 | add("EDA establishes the comparison",c("Profiles, missingness, skewness, ceiling effects, and imbalance","Raw questionnaire fields retain additional substantive information"),"The full EDA tables are available, including every derived variable and the raw-field inventory. Do not read every imbalance as a hypothesis test. Emphasize sparse ordinal categories, skewed losses, and different household compositions.","balance",minutes=1) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0017 | add("An analysis map, not a model contest",c("Measurement: EFA → theory CFA; PCA as description","Associations: ordinal, score, Bayesian, and nonlinear models","Mechanisms: PLS paths, interaction, MGA","Stress tests and prediction answer separate questions"),"Explain why methods are complementary. The best predictive model does not identify a policy effect. CFA fit does not prove a mechanism. A PLS composite does not automatically represent an error-free latent variable.",minutes=2) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0018 | add("What is reflective, formative, or observed?",c("Tolerance: reflective hypothesis under examination","Institutions and tangible costs: formative components","CE0 and ecological value: observed single items","Item meanings constrain admissible models"),"Avoid using low alpha as a reason to relabel a construct formative. Institutional contact counts and information channels are behaviors, not interchangeable symptoms of fatigue. Reflective diagnostics such as HTMT must be interpreted within this distinction.",minutes=2) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0019 | add("EFA: the expected structure is not assured",c("Ordinal polychorics, minres extraction, oblimin rotation","Parallel analysis and identification must be read together"),"The development split has 316 respondents and only 238 complete eight-item records. Pairwise polychorics use available pairs. The parallel suggestion of four factors among eight items is not an identified four-factor questionnaire model. The two-factor EFA has a Heywood problem; report it openly.","parallel_analysis",minutes=2) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0020 | add("CFA: internal validation, not independent replication",c(paste0("Three-item tolerance two-factor validation: CFI ",fmt(cfa$cfi.scaled),", RMSEA ",fmt(cfa$rmsea.scaled)),"Village-disjoint development and validation partitions","Weak word-item loadings and factor overlap remain"),"Use the holdout to assess fixed theory models rather than optimize modification indices. The dataset was previously seen, so do not call this independent confirmation. Explain that a standalone three-item factor is just-identified and its perfect fit would not validate it. Factor orientation is arbitrary; compare absolute latent correlations.",minutes=2) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0021 | add("PCA describes variance; it does not validate constructs",c("Standardized complete-case item PCA","Loadings and explained variance supplied","PCA components are not latent causes, IRT, or PLS-SEM"),"PCA answers a variance-reduction question. It is useful for checking whether scoring changes the picture, but choosing a component to maximize the application coefficient would be selective analysis. Keep it separate from the substantive construct argument.",minutes=1) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0022 | add("The HTMT question",c("Historical 1.112 must be reassessed after coding corrections","Corrected reflective cost/tolerance diagnostics still show overlap","HTMT is not a pass/fail rule for formative institutional contact"),"This directly answers Mengxi's question. Revisit the indicators before merging constructs. The rebuilt reflective cost/tolerance HTMT is high, consistent with overlapping attitudinal content and weak word-item coherence. Institutional contact should not be renamed governance fatigue based on a correlation.",minutes=2) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0023 | add("Primary estimands and uncertainty",c("Four ordinal outcomes; Holm adjustment within each model family","Unadjusted → background → resources → explanatory","County effects; township-clustered uncertainty","Report probabilities and intervals, not just p-values"),"The adjustment sequence changes the interpretation. The explanatory model conditions on simultaneous attitudes and potential mediators. It does not estimate the total policy effect. Explain finite-cluster t inference with 25 townships and why village clustering is a sensitivity.",minutes=2) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0024 | add("Item-level results differ",c("The strongest background-adjusted signal concerns non-lethal management."),"Point out the negative application association for Tol1, uncertainty for other items after Holm adjustment, and little adjusted association for safety. The stronger resource-adjusted Tol2/Tol4 estimates appear in backup tables. Do not summarize all outcomes as the same psychological response.","primary_ordinal",minutes=2) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0025 | add("Composite results depend on the definition",c("Three- and four-item scores are secondary summaries."),"Read the outcome-SD scale carefully. Equal raw-item means differ from the earlier mean-z-score construction. A change in coefficient size can reflect the outcome definition and adjustment, not an algorithm discovering a new causal effect.","score_associations",minutes=2) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0026 | add("Ordinal assumptions and Bayesian checks",c(paste0(sum(bay$diagnostics_pass),"/4 Bayesian models passed the prespecified MCMC checks"),"Township random intercepts; weakly informative priors","Nonparallel slopes and sparse-category fits remain concerns"),"Four chains, R-hat at most 1.01, ESS at least 400, and no divergences are computational checks. Posterior predictive plots are provided. Some proportional-odds diagnostics indicate deviations; a Tol2 partial model has a singular Hessian. Do not claim that Bayesian estimation solves these substantive assumptions.",minutes=1.5) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0027 | add("PLS-SEM: compare specified models",c("Baseline; mediation; conflict/prevention extension","Three vs four tolerance items; IC1-only sensitivity","Standard PLS-PM; full measurement refit in the bootstrap"),"The main model uses formative cost and institution blocks, observed application/benefit, and a reflective tolerance specification. We report weights, loadings, VIF, reliability where applicable, R², f² and SRMR. Fit and explained variance do not establish causality or construct validity.",minutes=2) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0028 | add("Direct and indirect associations",c("Intervals come from 5,000 county-stratified township resamples."),"The direct negative path persists, but both proposed indirect intervals cross zero. The institutional and cost indirect paths have opposite signs and almost cancel. Distinguish standardized PLS paths from the two-stage raw 0/1 application interaction. One bootstrap fit was inadmissible and was recorded, not replaced.","pls_paths",minutes=2) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0029 | add("The proposed mechanisms remain uncertain",c(paste0("Direct path: ",getci("direct")),paste0("Indirect via costs: ",getci("indirect_IC")),paste0("Indirect via institutions: ",getci("indirect_PS")),"These data do not demonstrate governance fatigue."),"This is an important departure from earlier reports. Even a nonzero indirect product would need temporal and confounding assumptions to support causal mediation. Here uncertainty already prevents a strong statistical mediation claim.",minutes=1.5) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0030 | add("Small interaction; uncertain group differences",c(paste0("Interaction: ",getci("interaction")),paste0("Interaction f² = ",fmt(ci$estimate[ci$parameter=="interaction_f2"])),"All four cluster-bootstrap MGA intervals include zero","No strong difference is not proof of equivalence"),"Keep the prespecified interaction in the exploratory results. Do not delete it to make the model appear stronger. MICOM is a conventional supporting diagnostic; means/variances are not fully invariant. Group-standardized paths are not identical to common-scale observed interactions.",minutes=1.5) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0031 | add("Secondary findings use more of the fieldwork",c("Agricultural dependence and prevention deserve attention","Applicant timeliness/satisfaction estimates are uncertain","Insurance preferences, channels, crops, and seasons are profiled","Secondary family uses BH multiplicity adjustment"),"The aim is useful substantive coverage, not accumulating significant results. Adoption and conditional effectiveness answer different questions. Payment text and prevention expenditure are incomplete; payout/loss ratios and causal cost-effectiveness rankings are withheld. Original word counts await human thematic review.",minutes=1.5) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0032 | add("How much can we predict?",c(paste0("Best observed grouped-CV RMSE: ",fmt(best$RMSE)," (",best$method,")")),"Five outer and three inner township folds prevent community leakage. Scaling and imputation are trained within folds. Differences among the leading models are small and do not prove linearity. Held-out importance is predictive reliance, not causal importance.","prediction",minutes=1.5) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0033 | add("Cross-fitting checks adjusted associations",c(paste0("Five AIPW contrasts: ",fmt(min(aipw$estimate_raw))," to ",fmt(max(aipw$estimate_raw))," raw score points"),"Nuisance models predict unseen townships","Overlap and balance are checked; causal assumptions remain"),"Explain the orthogonal-style score without presenting DML as an automatic confounding cure. Only background/resources enter nuisance models. Repeated splits check algorithmic sensitivity, not five independent replications. Report propensity ranges and effective sample size.",minutes=1.5) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0034 | add("A transparent specification curve",c(paste0(nrow(spec)," distinct model/uncertainty combinations; outcomes shown separately")),"We vary reasonable decisions and deduplicate identical inputs. This is not a search for significance. A percentage of negative estimates is not a probability of robustness. Invalid reverse coding is not a reasonable alternative. The safety item should not be hidden among composite results.","specification_curve",minutes=2) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0035 | add("Stress-test the observations and assumptions",c(paste0("Leave-one-township contrast range: ",fmt(min(jk$estimate))," to ",fmt(max(jk$estimate))),"Village clustering; county checks; extreme-loss sensitivity","Unresolved-value handling and confounding-strength grid","All failures and model choices remain visible"),"Influence tests assess whether a small number of observations or communities dominate the result. They do not address all unmeasured confounding. The bias grid is a linear point-estimate sensitivity, not a cluster-adjusted causal confidence interval.",minutes=1) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0036 | add("What can we defend?",c("Applicants report lower tolerance on several management dimensions","Measurement and outcome choice materially affect the story","The proposed mediation and moderation are not established","Policy failure is not identified by this survey"),"Offer the most defensible interpretation in plain language. Compensation application may mark respondents with different experiences, expectations, and institutional contact. Multiple explanations remain compatible with the data. A causal policy evaluation needs timing and a credible design.",minutes=1.5) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0037 | add("What remains for the final report?",c("Clarify sampling, exclusions, payment timing, percentages, and units","Resolve methodological questions from today's discussion","Amend the decision register and rerun affected analyses","Preserve the presentation release for comparison"),"All available-data analyses are reproducible today. Future work is substantive clarification and response to feedback, not inventing causal identification. Clearly separate information unavailable in the workbook from computational tasks already completed.",minutes=1) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0038 | add("Discussion",c("Which tolerance dimensions matter for the policy question?","What evidence would distinguish selection from policy effects?","Which measurement interpretation is defensible?"),"Invite methodological criticism. Have the following backup slides and the full report ready. Allocate 15 minutes to discussion and record questions for the three-week final-report revision.",minutes=.5) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0039 | add("Backup: direct answers to Mengxi",c("Measurement: no clean, automatic latent structure","HTMT: diagnose reflective blocks; do not merge formative behaviors blindly","Moderation: small and uncertain; MGA: no strong difference","Interpretation: association, not demonstrated causal mediation"),"Use this as the checklist that every item of the Exploratory Contribution was addressed. The full report contains the explicit question-to-answer mapping.",backup=TRUE) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0040 | add("Backup: selection and causal direction",c("Application is voluntary and measured cross-sectionally","County, losses, attitudes, and institutions can shape selection","Cross-fitting removes training reuse, not unmeasured confounding","No valid instrument or longitudinal policy comparison is established"),"If asked for an ATE, explain the identification assumptions and why our adjusted contrasts do not establish them. Conditioning on current attitudes can block or distort paths; a statistical arrow is not temporal evidence.",backup=TRUE) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0041 | add("Backup: why not interpret nonsignificance as equality?",c("Group differences can be imprecise","Equivalence needs a justified margin and adequate precision","Group-standardized coefficients depend on variance","MICOM non-rejection is not proof of full invariance"),"A nonsignificant MGA is supplementary evidence of no clear difference, exactly as Mengxi suggested. The study did not specify a substantive equivalence margin, so it cannot claim equivalent mechanisms.",backup=TRUE) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0042 | add("Backup: posterior predictive check",c("MCMC diagnostics and model fit answer different questions."),"Compare observed response frequencies with replicated frequencies. The remaining three item plots and all diagnostics are available in the report outputs.","bayes_ppc_tol1",backup=TRUE) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0043 | add("Backup: propensity overlap",c("Inspect support, balance, clipping, and effective sample size."),"Overlap in the fitted propensity distribution does not prove overlap on unobserved confounders. The exported balance table shows how observed differences change after weighting.","overlap",backup=TRUE) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0044 | add("Backup: p-hacking safeguards",c("Dated plan; prior inspection disclosed","Full results and failures; no significance-driven deletion","Deduplicated specifications; multiplicity; internal validation","No p-curve or certificate of 'no p-hacking'"),"Explain that the appropriate safeguard is transparent analytical practice. P-curve on correlated tests from this single sample would not establish the absence of selective reporting.",backup=TRUE) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0045 | add("Backup: missingness and anomalies",c("Structural payment missingness is never imputed","Word zeros are absent answers, not positive sentiment","Percentages above 100% are flagged, not guessed","Median/mode sensitivity is limited, not full multiple imputation"),"The transformation log identifies exactly which values changed and why. One missing raw Tol1 changes the score sample from 625 to 624. Main PLS complete cases number 622 because reporting responses are also missing.",backup=TRUE) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0046 | add("Backup: reproducibility",c("R targets pipeline and renv lockfile","Source/data hashes, seeds, grouped folds, model objects","Reports and slides read the same saved tables","One build command; separate render and validation commands"),"Commands: Rscript run_project.R --restore; Rscript run_project.R; Rscript run_project.R --render; Rscript run_project.R --verify. A rebuild should not rely on an RStudio workspace or .RData.",backup=TRUE) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0047 | add("Backup: methodological references",c("lavaan: categorical WLSMV; psych: EFA and parallel analysis","cSEM: PLS-PM and MICOM; brms: ordinal multilevel models","Simonsohn et al. (2020): specification curve analysis","DoubleML: cross-fitting and sensitivity assumptions"),"Clickable references and full URLs are in the report and PLAN.md. These guide method choices; they do not validate the present dataset automatically.",backup=TRUE) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0048 | slides | Executes a supporting calculation, option, or output step for this module. |
| 0049 | } | Executes a supporting calculation, option, or output step for this module. |
| 0050 | render_deliverables<-function(){ | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0051 | Sys.setenv(WILDBOAR_ROOT=ROOT) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0052 | # Additional presentation-ready variance figure. | Comment documenting the intent or an analytical decision; it does not execute. |
| 0053 | pv<-read_result("pca_variance") | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0054 | plot_save("pca_variance",ggplot2::ggplot(pv,ggplot2::aes(component,variance))+ggplot2::geom_col(fill="#327f91")+ggplot2::labs(x="Component",y="Proportion of variance",title="PCA: variance description, not construct validation")+ggplot2::theme_minimal(base_size=12)) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0055 | slides<-make_slides();slides[[13]]$figure<-"pca_variance" | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0056 | # Scale declared main-talk timings to exactly 45 minutes. | Comment documenting the intent or an analytical decision; it does not execute. |
| 0057 | main<-!vapply(slides,`[[`,logical(1),"backup");total<-sum(vapply(slides[main],`[[`,numeric(1),"minutes")) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0058 | for(i in which(main))slides[[i]]$minutes<-slides[[i]]$minutes*45/total | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0059 | p<-officer::read_pptx();notes<-c("# Speaker notes: 45-minute talk + 15-minute discussion","");md<-c("% Compensation application and wild-boar tolerance","% Statistical consulting for Mengxi Kou","% 17 September 2026","") | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0060 | for(i in seq_along(slides)){ | Executes a supporting calculation, option, or output step for this module. |
| 0061 | s<-slides[[i]];p<-officer::add_slide(p,layout="Blank",master="Office Theme") | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0062 | title<-officer::fpar(officer::ftext(s$title,officer::fp_text(font.size=25,bold=TRUE,color="#16324F",font.family="Arial"))) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0063 | p<-officer::ph_with(p,title,location=officer::ph_location(left=.45,top=.3,width=9.1,height=.8)) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0064 | if(!is.null(s$figure)){ | Controls execution so checks, loops, or conditional sensitivity branches run reproducibly. |
| 0065 | p<-officer::ph_with(p,officer::external_img(file.path(OUT,"figures",paste0(s$figure,".png")),width=8.9,height=4.9),location=officer::ph_location(left=.55,top=1.3,width=8.9,height=4.9)) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0066 | body<-officer::fpar(officer::ftext(paste(s$bullets,collapse="\n"),officer::fp_text(font.size=15,color="#16324F",font.family="Arial"))) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0067 | p<-officer::ph_with(p,body,location=officer::ph_location(left=.55,top=6.2,width=8.9,height=.7)) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0068 | }else{ | Executes a supporting calculation, option, or output step for this module. |
| 0069 | for(j in seq_along(s$bullets)){ | Executes a supporting calculation, option, or output step for this module. |
| 0070 | body<-officer::fpar(officer::ftext(paste0("• ",s$bullets[j]),officer::fp_text(font.size=21,color="#223344",font.family="Arial"))) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0071 | p<-officer::ph_with(p,body,location=officer::ph_location(left=.7,top=1.5+(j-1)*1.12,width=8.6,height=1.02)) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0072 | } | Executes a supporting calculation, option, or output step for this module. |
| 0073 | } | Executes a supporting calculation, option, or output step for this module. |
| 0074 | foot<-officer::fpar(officer::ftext(paste0(if(s$backup)"DISCUSSION BACKUP"else"PRESENTATION RELEASE • 17 SEPT 2026"," | ",i),officer::fp_text(font.size=9,color="#64748B"))) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0075 | p<-officer::ph_with(p,foot,location=officer::ph_location(left=.5,top=7.12,width=9,height=.2)) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0076 | note<-paste0(if(s$backup)"Backup slide"else paste0("Target time: ",round(s$minutes,1)," minutes"),"\n",s$notes) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0077 | p<-officer::set_notes(p,value=note,location=officer::notes_location_type("body")) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0078 | notes<-c(notes,paste0("## ",i,". ",s$title),"",note,"",paste0("- ",s$bullets),"") | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0079 | md<-c(md,paste0("## ",if(s$backup)"Backup: "else"",s$title),"",paste0("- ",s$bullets),"") | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0080 | if(!is.null(s$figure))md<-c(md,paste0("),"){height=60%}"),"") | Controls execution so checks, loops, or conditional sensitivity branches run reproducibly. |
| 0081 | } | Executes a supporting calculation, option, or output step for this module. |
| 0082 | ppt<-file.path(OUT,"presentation/Wildboar_Consulting_Presentation.pptx");print(p,target=ppt) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0083 | writeLines(notes,file.path(OUT,"presentation/Speaker_Notes.md")) | Persists a table, model, figure, or report artifact so results are inspectable outside R. |
| 0084 | writeLines(md,file.path(OUT,"presentation/Slides.md")) | Persists a table, model, figure, or report artifact so results are inspectable outside R. |
| 0085 | jsonlite::write_json(slides,file.path(OUT,"presentation/slide_content.json"),pretty=TRUE,auto_unbox=TRUE) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0086 | # Render an accessible narrative report and a printable version from identical sources. | Comment documenting the intent or an analytical decision; it does not execute. |
| 0087 | html<-rmarkdown::render(file.path(ROOT,"docs/Analysis_Report.Rmd"),output_format="html_document",output_file="Analysis_Report.html",output_dir=file.path(OUT,"report"),quiet=TRUE,envir=new.env()) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0088 | pdf<-rmarkdown::render(file.path(ROOT,"docs/Analysis_Report.Rmd"),output_format="pdf_document",output_file="Analysis_Report.pdf",output_dir=file.path(OUT,"report"),quiet=TRUE,envir=new.env()) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0089 | slidepdf<-file.path(OUT,"presentation/Wildboar_Consulting_Presentation.pdf") | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0090 | status<-system2("pandoc",c(shQuote(file.path(OUT,"presentation/Slides.md")),"-t","beamer","--pdf-engine=xelatex","-V","theme:default","-V","colortheme:dolphin","-V",shQuote("mainfont:DejaVu Sans"),"-o",shQuote(slidepdf)),stdout=file.path(OUT,"logs/slides_pdf.log"),stderr=file.path(OUT,"logs/slides_pdf.log")) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0091 | if(status!=0)stop("Presentation PDF rendering failed; see slides_pdf.log") | Controls execution so checks, loops, or conditional sensitivity branches run reproducibly. |
| 0092 | files<-c(list.files(file.path(ROOT,"src/fresh"),full.names=TRUE),file.path(ROOT,c("_targets.R","run_project.R","docs/PLAN.md","docs/ANALYSIS_DECISIONS.md","docs/Analysis_Report.Rmd","data/3_Data.xlsx"))) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0093 | manifest<-list(created_utc=format(Sys.time(),tz="UTC",usetz=TRUE),seed=SEED,data_sha256=digest::digest(file=file.path(ROOT,"data/3_Data.xlsx"),algo="sha256"),source_hashes=setNames(lapply(files,function(p)digest::digest(file=p,algo="sha256")),sub(paste0(ROOT,"/"),"",files,fixed=TRUE)),session=capture.output(sessionInfo()),main_slides=sum(main),backup_slides=sum(!main),talk_minutes=sum(vapply(slides[main],`[[`,numeric(1),"minutes"))) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0094 | jsonlite::write_json(manifest,file.path(OUT,"run_manifest.json"),pretty=TRUE,auto_unbox=TRUE) | Creates or updates an analysis object; this stores an intermediate result used by later lines. |
| 0095 | c(ppt,html,pdf,slidepdf,file.path(OUT,"presentation/Speaker_Notes.md"),file.path(OUT,"run_manifest.json")) | Executes a supporting calculation, option, or output step for this module. |
| 0096 | } | Executes a supporting calculation, option, or output step for this module. |