You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried to use the following code to "compile" a file using knitr. However, if I do it, then all header definition (in LaTeX) are not included in the resulting file.
require(knitr)
filename<-"test2.Rnw"## Setting error and warning hooksknit_hooks$set(error=
local({
error_list<-list()
error_counter<-0function(x, options){
error_list[[options$label]] <<- c(error_list[[options$label]], x)
error_counter<<-error_counter+1
}
}))
knit_hooks$set(warning=local({
warning_list<-list()
warning_counter<-0function(x, options){
warning_list[[options$label]] <<- c(warning_list[[options$label]], x)
warning_counter<<-warning_counter+1
}
}))
## Knitting fileres<- tryCatch({
knit(filename)
NULL
}, error=function(e) e)
## Getting number of R errorserror_count<- environment(knit_hooks$get("error"))$error_counterif(is.null(res) &&error_count<1) { ## No error by knitr
cat(filename, " success\n\n", file=stdout())
}elseif(error_count>0){
error_list<- environment(knit_hooks$get("error"))$error_listfor(nin names(error_list)){
cat("Error(s) in chunk: " , n, "\n", file=stderr())
for(einerror_list[[n]]){
cat("\t", e,"\n", file=stderr())
}
cat("\n", file=stderr())
}
} else{ ## Error in knitr
cat("\n\nknitr error: ", as.character(res), "\n\n", file=stderr())
}
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.
otherwise users may never realize them
The text was updated successfully, but these errors were encountered: