Skip to content

Question: how to define the scope of inline chunks #1853

@courtiol

Description

@courtiol

Dear @yihui and colleagues, this is a rather technical question (see link to RStudio community at the end)

Within a package I am working on, I am creating optional vignettes that the user can build on demand.

I would like the building of such vignettes happens in an environment that does not have the global one as parent.
So, my custom vignette building function includes something like:

vignette_env <- new.env(parent = baseenv())
rmarkdown::render(path.to.file, envir = vignette_env)

The problem, when I do that, is that the package loaded and the objects created inside knitr chunks are not visible (in scope) to inline calls that follow, although they are visible to other chunks.

I don't understand why and how to cope with this scoping issue.

I have posted a question on RStudio community with a full reprex (https://community.rstudio.com/t/scoping-environment-struggle-in-r-markdown/70709), but failed to attract any attention in more than a week.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions