-
-
Notifications
You must be signed in to change notification settings - Fork 968
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
rmarkdown::render within function gives error #934
Comments
I wasn't able to reproduce this issue, although perhaps I wasn't clear on your instructions. With an R Markdown document containing this:
I was able to successfully render this document with this:
Perhaps the issue is with
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.2
locale: attached base packages: other attached packages: loaded via a namespace (and not attached): |
@kevinushey: Thanks for your response! Sorry for my unclear explanation of the problem, but you interpreted it correctly. I've updated my # Method 1
my_render <- function(input) {
rmarkdown::render(input = input)
}
my_render(input = "~/scratch/test.Rmd") |
Sounds like an environment issue. How about passing |
Thanks @yihui! That solved my problem. |
I can definitely see why you feel confused. It is related to the delayed evaluation of function arguments. In a recent interview of @jcheng5, he said:
Even though If you pass an explicit That said, whenever someone runs into an issue similarly, I'm relatively sure it is a bug of the third-party package that is used in R Markdown (the package can not work with well objects in parent frames, e.g. it might have assumed objects must be in the global environment). In this case, phyloseq might be the culprit, but I know nothing about it, so I'm not entirely sure. |
Wow, thanks again @yihui! I did not expect (such) an (extensive) answer and really appreciate the effort you put into it. Your explanation is very clear and I will try to look into the assumptions of the phyloseq functions. |
@yihui Thanks so much man! This answer just saved the day for me also! |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
Hi,
I have a minor issue concerning a function I wrote containing
rmarkdown::render
. Specifically when using that function in combination with phyloseq-formatted data in a for-loop (or apply) gives an error while rendering.Minimal example
Function containing
rmarkdown::render
, that gives the error:rmarkdown::render on its own does not give the error:
Test example that always works
If test.Rmd contains this for-loop, everything is fine:
Test example with phyloseq data
However, if test.Rmd wants to loop phyloseq-data:
"Error in eval(expr, envir, enclos) : object 'x' not found"
.sessionInfo()
I am not really sure whether this is a rmarkdown or phyloseq issue, though.
Any support is appreciated. Thanks!
The text was updated successfully, but these errors were encountered: