The problem lay in how I specified the location of my output files in the render() function within my for loop.
This loop specified absolute file paths and in turn the image file locations were also being specified with absolute file paths.
dir_datasets <- here::here('data', 'cooked', 'gamma_a4_b0-04')
mdes <- c(.980, .990, .995, 1.010, 1.020, 1.030)
mdes_str <- broman::myround(mdes, 3)
my_files <- list.files(dir_datasets)
for (mde in mdes) {
for (file in my_files){
TRUE_EFFECT <- extract_string_from_filename(file, 3)
MDE_TITLE <- dash4dot(mde, 3)
rmarkdown::render(
fs::path(dir_sprt_ttest, 'template.Rmd'),
output_file = fs::path(
dir_output, paste0('tte', TRUE_EFFECT, '_mde', MDE_TITLE, '.md')
),
params = list(file_name = file, mde = mde)
)
}
}
When I remove the absolute filepath from the output_file argument in render() the images were thereafter saved with relative filepaths, too, and the .md files displayed their images after being pushed to GitHub.
output_file = paste0('tte', TRUE_EFFECT, '_mde', MDE_TITLE, '.md') # note that I dropped fs::path(dir_output,