Skip to contents

A JAGS/BUGS model (model { ... }) is written in JAGS's own modelling language, not R, and is meant to be passed as a text file to rjags::jags.model()/R2jags::jags()/runjags::run.jags(), never parsed as R directly — authors frequently save one with a .R extension, which then fails code_parse_r() and reads identically to a genuine broken R script. Matched via three signals, any one of which is treated as sufficient (the third — an actual calling reference from the paper's own code — is the strongest, since it confirms the paper's own code treats this file as a JAGS model rather than something to run directly):

Usage

.repro_is_jags_model(code_text, file_name = "", other_code_text = NULL)

Arguments

code_text

the file's raw text (character vector, one element per line)

file_name

the file's own name/path (checked for a jags_script/ bugs_script/jags_model path component)

other_code_text

optional list of OTHER files' code text (e.g. the paper's other R files) to scan for a jags.model()/jags()/run.jags() call naming this file — NULL skips this (strongest) signal

Value

TRUE when any signal matches, else FALSE

Details

  1. the file's first non-comment, non-blank content is the token model followed by {, also on the next line, or a data { ... } block with a model block after it;

  2. its path contains a component named jags_script/bugs_script/ jags_model (case-insensitive);

  3. it is referenced elsewhere in the SAME paper's own R code as the file=/first argument to rjags::jags.model(), R2jags::jags(), or runjags::run.jags().