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

Creating plan in Rmd file - knit() same chunk names #330

Closed
rkrug opened this issue Mar 19, 2018 · 8 comments
Closed

Creating plan in Rmd file - knit() same chunk names #330

rkrug opened this issue Mar 19, 2018 · 8 comments

Comments

@rkrug
Copy link
Contributor

rkrug commented Mar 19, 2018

I am creating a drake plan in an R notebook for documentation purposes. The planknits at the end a. Rmd file:

plan %<>% bind_rows(
  drake::drake_plan(
    knit(
      knitr_in( "TESTRmd" ), 
      file_out( "TEST.html" ), 
      quiet = TRUE
    )
  )
)

at the same time, I have a setup chunk in the Rmd which creates plan as well as in the file TEST.Rmd This results in the file not be parsed. I know this is an unusual use (creating the plan in an R notebook).

@wlandau
Copy link
Member

wlandau commented Mar 19, 2018

Sorry, I am having trouble understanding the problem. Is make() not working correctly, or does drake_plan() complain that it cannot find TEST.Rmd? Are you creating TEST.Rmd before creating the drake_plan() that uses it?

@wlandau
Copy link
Member

wlandau commented Mar 19, 2018

Ah, just re-read the title: I think TEST.Rmd cannot have conflicting chunk names with your R notebook. I encountered similar problems with drake vignettes that run examples with a report.Rmd.

@wlandau
Copy link
Member

wlandau commented Mar 19, 2018

Closing because I assume this problem is related to duplicate chunk names (chunk names need to be unique among all the reports). Please correct me if I am wrong, and I will reopen.

@wlandau wlandau closed this as completed Mar 19, 2018
@rkrug
Copy link
Contributor Author

rkrug commented Mar 20, 2018 via email

@wlandau
Copy link
Member

wlandau commented Mar 20, 2018

I do agree, but drake cannot fix the issue of nested colliding reports because it has no control over the internals of knitr.

@rkrug
Copy link
Contributor Author

rkrug commented Mar 20, 2018

No - it can't. But shouldn't creating a target, be independent from where it is build?

This leads to the question already partly raised: how dependent is the target from the environment it is called in? How do loaded packages affect the result? Can local variables change the result?

> plan <- drake_plan(test = x + 1)
> make(plan)
target test
fail test
Error: Target `test`` failed. Call `diagnose(test)` for details. Error message:
  object 'x' not found
> x <- 1
> make(plan)
target test
>

should always result in the same result, i.e. the error message. I don't know if it is possible anymore without breaking backward compatibility, but I think make() should start its own R --vanilla session and do all compiling of targets in there to avoid the effect of accidental leftover local variables.

The fact that local variables are accessible during make() make life easier in many situations, but they are against the idea that a call to make() should result in reproducible results.

@wlandau
Copy link
Member

wlandau commented Mar 20, 2018

We can think about a separate session for make(). See #296 (comment).

@rkrug
Copy link
Contributor Author

rkrug commented Mar 20, 2018

Sounds good. Thanks.

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

2 participants