Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keeping track of source code for figures #17

Open
friendly opened this issue Oct 18, 2024 · 1 comment
Open

Keeping track of source code for figures #17

friendly opened this issue Oct 18, 2024 · 1 comment

Comments

@friendly
Copy link
Owner

For editing, and then later for production, I need to keep track of where the source code is for each figure generated in the scripts under R/. I've just started adding some of these, in the form of comments:

<!-- figure-code: R/prestige.R -->

Another reason to do this is that I anticipate making many of the scripts available with the online version of the book, as I did for my categorical data analysis book, Discrete Data Analysis with R: Visualization and Modeling Techniques for Categorical and Count Data.

Is there some way to add a knitr option, fig.code =, or Quarto option fig-code: with, a chunk-hook that for now does nothing, but could be modified later to do something useful, like adding the filename to the figure caption?

```{r prestige1, fig.code = "R/prestige.R">
#| fig-code: R/prestige.R
      ...
```

Where the NULL version would look like this:

knitr::opts_knit$set(fig.source = NULL)
@friendly
Copy link
Owner Author

I realized I can do something like this using a div to show the filename in the margin (for the HTML version), e.g.,

::: {.column-margin}
R file: `R/collin-data-beta.R`
:::

But to be truly useful, I'd like to be able to turn this off globally. Is there any way to do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant