Last active
April 3, 2022 19:21
-
-
Save jennybc/0239f65633e09df7e5f4 to your computer and use it in GitHub Desktop.
Generate a photo-gallery README for a directory of figs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## this snippet was the original gist but the Rmd solution below is even nicer | |
## auto-generate a visual index as README.md in current working directory | |
fig_files <- list.files(pattern = "jpg$") # change to png$ as needed! | |
writeLines(paste0(fig_files, "\n", | |
"![`", fig_files, "`](", fig_files, ")\n\n"), "README.md") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
output: | |
html_document: | |
keep_md: TRUE | |
--- | |
I added this file after seeing Hadley's suggestion to do this in an R markdown chunk. | |
```{r, results ="asis", echo = FALSE} | |
fig_files <- dir(pattern = "png$") | |
cat(paste0("* ", fig_files, " ![](", fig_files, ")\n")) | |
``` |
Good idea @hadley! I hate how I don't get notified of comments 😦 but glad to have eventually seen this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this might be better as an Rmarkdown block: