Error in getMetricsFromLatex(TeXMetrics, verbose = verbose) - r

When compiling R code within a child, I get the following error.
Error in getMetricsFromLatex(TeXMetrics, verbose = verbose) :
TeX was unable to calculate metrics for the following string
or character:
m
Common reasons for failure include:
* The string contains a character which is special to LaTeX unless
escaped properly, such as % or $.
* The string makes use of LaTeX commands provided by a package and
the tikzDevice was not told to load the package.
The file worked flawlessly until I changed one tiny detail that I cannot recall. The tikzDictionary is in the directory of the first child containing R-code. I removed the tikZDictionary to no avail. The file created is empty (0 Bytes). Taking the code and compiling it in a file with the appropriate headers works fine. I tried copying the contents of the whole thesis to a new folder and recompile it there, but the same problems occur there.
> sessionInfo()
> R version 3.4.0 (2017-04-21) Platform: x86_64-apple-darwin16.5.0 (64-bit) Running under: macOS Sierra 10.12.4
>
> Matrix products: default BLAS:
> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
> LAPACK:
> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
>
> locale: [1]
> en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages: [1] stats graphics grDevices utils
> datasets methods base
>
> other attached packages: [1] tikzDevice_0.10-1 plyr_1.8.4
> xtable_1.8-2 knitr_1.15.1
>
> loaded via a namespace (and not attached): [1] compiler_3.4.0
> magrittr_1.5 tools_3.4.0 Rcpp_0.12.10 [5]
> codetools_0.2-15 filehash_2.4-1 stringi_1.1.5 highr_0.6
> [9] grid_3.4.0 digest_0.6.12 stringr_1.2.0 evaluate_0.10
Copying all relevant files to a new directory and trying to compile it throws the same error.
1) Can one try to force the tikZdevice to recalculate the metrics?!
2) Can I get the correct metrics from elsewhere?
Thank you so much for your help.
I got it to work after a total of about 6 hours. I put all the R-Code in the main file, it compiles flawlessly. The ´main-tikzDirectory´ is in the same directory as the ´main´.
However, it is about 1000 lines of R code (we're talking about the results party of my whole thesis...), which I would rather have in a separate file.
As soon as I place anything in a child I get the same error. Also, while the error had been thrown in the ´R´ console before and no tex file is produced, when using the minimal example below the error message is written to the tex-file.
I provide a minimal example:
\documentclass[10pt,a4paper]{book}
\usepackage{geometry} % Titelseite braucht eigene Margins.
%\usepackage[ngerman]{babel} % Trennungsregeln, Datumsangabe etc. in Deutsch
\usepackage[T1]{fontenc} % europäischer Zeichensatz (Sonderzeichen, etc.)
%\usepackage[bitstream-charter]{mathdesign} % Moderne, serifenbetonte und sachliche Schriftart
\usepackage[utf8]{inputenc} % utf8 Eingabezeichensatz
\usepackage{xstring} % Testen/Vergleichen von (Sub)Strings
\usepackage{totcount} % Zähle Seitenzahlen, Abbildungen etc.
\usepackage{siunitx} % SI Einheiten
\DeclareSIUnit{\molar}{M}
%\usepackage{natbib} % Naturwissenschaftliche Zitierungen
\usepackage[sorting=none, citestyle=nature, maxnames=99, minnames=99, backend=biber]{biblatex}
\addbibresource{bibliography/bibliography.bib}
\renewcommand*{\bibfont}{\small}
\usepackage[version=3]{mhchem} % chemische Summen- und Strukturformeln
\usepackage{eurosym} % Euro-Zeichen
\usepackage{hyperref} %
\usepackage[xindy,acronym,nonumberlist,nomain]{glossaries} % Abkürzung + Abkürzungsverzeichnis
\makeglossaries %
\usepackage{multicol}
% Grafiken
\usepackage{tikz}
\usepackage{epsfig}
\usepackage{graphics}
\usepackage{graphicx}
% Tabellen
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{tabu}
\usepackage{array}
\usepackage{rotating}
\usepackage{bigdelim}
\usepackage{multirow}
\usepackage{float}
\usepackage{colortbl}
\usepackage{xcolor}
\def\TReg{\textsuperscript{\textregistered}}
\def\TCop{\textsuperscript{\textcopyright}}
\def\TTra{\textsuperscript{\texttrademark}}
%% Nummerierung
\setcounter{secnumdepth}{4}
%% Eigene Makros
\input{config/config}
\input{macros/InOderAm}
\input{macros/HideIfZero}
\input{macros/citenumCounter}
\input{macros/totalfiguresCounter}
\input{macros/totalappendixCounter}
%% Floats erst ab 80% auf eigene Seite
\renewcommand{\floatpagefraction}{.8}%
%% Dokument
\begin{document}
%% Knitr-optionen
<<setup, echo = FALSE, results= 'hide', message = FALSE>>=
library(xtable)
library(plyr)
opts_chunk$set(fig.path='figure/graphics-', cache.path='cache/graphics-', fig.align='center', dev='tikz', external=TRUE, fig.width=5, fig.height=5, fig.show='hold', cache=TRUE, global.par=FALSE)
knit_hooks$set(par=function(before, options, envir){
if (before && options$fig.show!='none') par(mar=c(4,4,.1,.1),cex=1,cex.lab=.9,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3)
}, crop=hook_pdfcrop)
#
<<results, child="content/main/results/results2.Rnw">>=
#
\end{document}
The child is located some folders below.
<<corruption>>=
plot(runif(100,0,1)^2)
#

Related

Local images in DT call not being written to _site directory

Question
How can I get each local image that is only referenced in a DT call to render to the _site directory so that it shows up in the site? Any suggestions or guidance would be much appreciated.
I reviewed this and this SO question.
Context
I am working in a Quarto website, but I get similar results from R Markdown.
I have a large number of image files in a series of sub-directories. These files correspond to records in a data frame (location, material, etc). Using the DT library, I would like to display the table and include the image files.
Problem
After rendering the website, local images only referenced within the DT call are not written out to the _site directory. However, if I reference an image using html that I pull directly from a data frame cell (i.e. df$imagefile[1]), the image is written to the _site directory and thus shows both in the html and the DT.
Without html chunk.
With html chunk.
Repro
Create a new Quarto website and add the code below to the index.qmd file.
First render the document without the final html chunk and no images will show.
Delete the _site directory and restart R.
Re-render the document including the html chunk and the first table image will show along with another copy below the table.
Note, sometimes once an image is knit is seems to remain in memory even if deleted. I've found it useful to both delete _site and restart R.
#| echo: false
knitr::opts_chunk$set(
echo = FALSE,
message = FALSE
)
#| label: libraries
library(dplyr)
library(DT)
#| label: create-dirs
main_dir <- here::here()
sub_dir <- "data"
sub_dir2 <- "data/Images"
# Check first dir
if (file.exists(sub_dir)){
} else {
dir.create(file.path(main_dir, sub_dir))
}
# Check second dir
if (file.exists(sub_dir2)){
} else {
dir.create(file.path(main_dir, sub_dir2))
}
#| label: make-images
jpeg(filename = "data/Images/2347.jpg")
plot(rnorm(25))
jpeg(filename = "data/Images/2348.jpg")
plot(rnorm(25))
jpeg(filename = "data/Images/2349.jpg")
plot(rnorm(25))
dev.off()
#| label: generate-list-make-df
image_list <- list.files("data/Images", full.names = TRUE)
df <- data.frame(imagefile = image_list)
df <- df |>
mutate(imagefile = paste0("<a href='",
imagefile,
"' target = 'blank'>",
"<img src='",
imagefile,
"' width = '125'></a></img>"))
datatable(df, escape = FALSE)
Final html chunk
Render first without and then again with the following chunk.
<a href='/data/Images/2347.jpg' target = 'blank'><img src='/data/Images/2347.jpg' width = '125'></a></img>
Session Info
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
1 LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
attached base packages:
1 stats graphics grDevices datasets utils methods base
loaded via a namespace (and not attached):
1 compiler_4.2.1 here_1.0.1 fastmap_1.1.0 cli_3.4.1 rprojroot_2.0.3 htmltools_0.5.2 tools_4.2.1
[8] yaml_2.3.6 rmarkdown_2.17 knitr_1.40 xfun_0.33 digest_0.6.30 rlang_1.0.6 renv_0.15.5
[15] evaluate_0.16

knitr cannot find pdflatex when creating pdf from shiny app

I am trying to create a shiny App that offers users a choice of canned reports from a database that renders reactively, and then offers users the option to download a pdf of their desired report. I am running into trouble getting knitr to discover pdflatex to make the pdf. I originally tried using MikTex, but on advice of other posts removed MikTex and instead used tinytex. I followed the guidance here: https://yihui.org/tinytex/r/#debugging. The shiny app works fine, but when I click the download button, R initially starts the process of compiling, but once I click save when the dialog button launches, R throws this error (I include the verbose output as suggested by Yuhui Xie - the tinytex package author):
processing file: Reports.Rmd
|.................. | 25%
ordinary text without R code
|.................................... | 50%
label: unnamed-chunk-1
|...................................................... | 75%
ordinary text without R code
|........................................................................| 100%
label: unnamed-chunk-2
output file: Reports.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS Reports.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output pandoc5ac42d2964ee.tex --lua-filter "C:\Users\SCMCKENZIE\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\SCMCKENZIE\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --highlight-style tango --pdf-engine xelatex --variable graphics --variable "geometry:margin=1in"
Warning: Error in : LaTeX failed to compile C:\Users\SCMCKE~1\AppData\Local\Temp\Rtmp0a6jRk\file5ac45df413ce.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips.
[No stack trace available]
Here is my SessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] plyr_1.8.6 rmarkdown_2.6 knitr_1.29
[4] tmap_3.3 rgeos_0.5-3 sp_1.4-1
[7] sf_0.9-7 xtable_1.8-4 readr_1.4.0
[10] shinydashboard_0.7.1 odbc_1.2.3 DBI_1.1.0
[13] shiny_1.5.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 lattice_0.20-41 png_0.1-7 class_7.3-17
[5] digest_0.6.25 mime_0.9 R6_2.4.1 evaluate_0.14
[9] e1071_1.7-3 pillar_1.4.6 rlang_0.4.7 rstudioapi_0.11
[13] raster_3.3-13 blob_1.2.1 stringr_1.4.0 htmlwidgets_1.5.1
[17] bit_1.1-15.2 tinytex_0.29 compiler_4.0.2 httpuv_1.5.4
[21] xfun_0.20 pkgconfig_2.0.3 tmaptools_3.1-1 base64enc_0.1-3
[25] htmltools_0.5.0 tidyselect_1.1.0 tibble_3.0.3 codetools_0.2-16
[29] XML_3.99-0.4 viridisLite_0.3.0 crayon_1.3.4 dplyr_1.0.0
[33] later_1.1.0.1 grid_4.0.2 jsonlite_1.7.0 lwgeom_0.2-5
[37] lifecycle_0.2.0 magrittr_1.5 units_0.6-7 KernSmooth_2.23-17
[41] stringi_1.4.6 promises_1.1.1 leafsync_0.1.0 leaflet_2.0.4.1
[45] ellipsis_0.3.1 generics_0.0.2 vctrs_0.3.2 RColorBrewer_1.1-2
[49] tools_4.0.2 dichromat_2.0-0 bit64_0.9-7 leafem_0.1.3
[53] glue_1.4.1 purrr_0.3.4 hms_0.5.3 crosstalk_1.1.0.1
[57] abind_1.4-5 parallel_4.0.2 fastmap_1.0.1 yaml_2.2.1
[61] stars_0.5-1 classInt_0.4-3
I have ensured that I have selected my Global Options in RStudio to use knitr and pdflatex. Sys.which('pdflatex') gives me:
pdflatex
"C:\\Users\\SCMCKE~1\\AppData\\Roaming\\TinyTeX\\bin\\win32\\pdflatex.exe"
And tinytex::tlmgr_conf() gives me:
tlmgr conf
=========================== version information ==========================
tlmgr revision 57424 (2021-01-15 03:30:58 +0100)
tlmgr using installation: C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX
TeX Live (https://tug.org/texlive) version 2020
==================== executables found by searching PATH =================
PATH: C:\Users\SCMCKE~1\AppData\Roaming\TinyTeX\tlpkg\tlperl\bin;C:\Users\SCMCKE~1\AppData\Roaming\TinyTeX\bin\win32;C:\rtools40\usr\bin;C:\Program Files\R\R-4.0.3\bin\x64;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Microsoft MPI\Bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\SCMCKENZIE\AppData\Roaming\TinyTeX\bin\win32;C:\Users\SCMCKENZIE\AppData\Local\Microsoft\WindowsApps;C:\Users\SCMCKENZIE\AppData\Local\Programs\MiKTeX\miktex\bin\x64
dvipdfmx: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/dvipdfmx.EXE
dvips: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/dvips.EXE
fmtutil: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/fmtutil.EXE
kpsewhich: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/kpsewhich.EXE
luatex: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/luatex.EXE
mktexpk: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/mktexpk.EXE
pdftex: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/pdftex.EXE
tex: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/tex.EXE
tlmgr: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/tlmgr.BAT
updmap: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/updmap.EXE
xetex: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/xetex.EXE
=========================== active config files ==========================
config.ps: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist/dvips/config/config.ps
fmtutil.cnf: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist/web2c/fmtutil.cnf
mktex.cnf: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist/web2c/mktex.cnf
pdftexconfig.tex: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist/tex/generic/tex-ini-files/pdftexconfig.tex
texmf.cnf: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf.cnf
texmf.cnf: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist/web2c/texmf.cnf
updmap.cfg: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist/web2c/updmap.cfg
============================= font map files =============================
kanjix.map: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var/fonts/map/dvipdfmx/updmap/kanjix.map
pdftex.map: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex.map
ps2pk.map: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var/fonts/map/dvips/updmap/ps2pk.map
psfonts.map: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var/fonts/map/dvips/updmap/psfonts.map
=========================== kpathsea variables ===========================
ENCFONTS=.;{C:/PROGRA~1/R/R-40~1.2/share/texmf,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}/fonts/enc//
SYSTEXMF=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var;C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local;C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist
TEXCONFIG={C:/PROGRA~1/R/R-40~1.2/share/texmf,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}/dvips//
TEXFONTMAPS=.;{C:/PROGRA~1/R/R-40~1.2/share/texmf,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}/fonts/map/{kpsewhich,pdftex,dvips,}//
TEXMF={C:/PROGRA~1/R/R-40~1.2/share/texmf,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}
TEXMFCONFIG=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config
TEXMFDBS={!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}
TEXMFDIST=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist
TEXMFHOME=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local
TEXMFLOCAL=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local
TEXMFMAIN=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist
TEXMFSYSCONFIG=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config
TEXMFSYSVAR=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var
TEXMFVAR=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var
TEXPSHEADERS=.;{C:/PROGRA~1/R/R-40~1.2/share/texmf,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}/{dvips,fonts/{enc,type1,type42,type3}}//
VARTEXFONTS=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var/fonts
WEB2C={C:/PROGRA~1/R/R-40~1.2/share/texmf,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}/web2c
==== kpathsea variables from environment only (ok if no output here) ====
In case it is a matter of my coding, below is a reproducible R script:
##Loading Necessary Packages
library(shiny)
library(shinydashboard)
library(rmarkdown)
library(knitr)
library(plyr)
##Getting data for reproducibility
data("iris")
data("airquality")
names(airquality)[5]<-"Species"#To allow for using the same plyr code in server function on both data sets
####Creating Shiny App####
##User Interface
ui<-dashboardPage(
dashboardHeader(title="FAKE SHINY APPLICATION"),
dashboardSidebar(
sidebarMenu(tabName="REPORTS",
menuItem("OPTIONS", tabName = "SOME MENU OPTIONS",
radioButtons(inputId = "REPORT", label = "Select Something", choices = c("Iris", "AQ")),
downloadButton(outputId = "DWNLD", "Download Report")
)
)
),
dashboardBody(
tableOutput(outputId = "TABLE"),
plotOutput(outputId = "PLOT")
)
)
##Server Function##
server<-function(input, output){
##Reactive Plot##
output$PLOT<-renderPlot({
RPT<-list(Iris = iris, AQ = airquality)
DF<-RPT[[input$REPORT]]
pairs(DF[,c(1:4)])})
##Reactive Table##
output$TABLE<-renderTable({
RPT<-list(Iris = iris, AQ = airquality)
DF<-RPT[[input$REPORT]]
rpt_tbl<-ddply(DF, "Species", colwise(mean))
xtable(rpt_tbl)
})
##Download As PDF##
output$DWNLD<-downloadHandler(
filename=paste(input$REPORT, "pdf", sep="."),
content<-function(file){
RPT<-list(iris, airquality)
names(RPT)<-c("Iris", "AQ")
tmp<-file.path(tempdir(), "Reports.Rmd")
file.copy(paste(getwd(),"Reports.Rmd", sep="/"), tmp, overwrite=TRUE)
params<-list(DF
rmarkdown::render(tmp, output_file = file,
params = params,
envir = new.env(parent = globalenv()
))#End render
}
)
}
##Launch Shiny App##
shinyApp(ui=ui, server = server)
And here is the script for the Rmarkdown document saved as Reports.Rmd:
---
title: "FAKE REPORT"
output: pdf_document
params:
DF: NA
---
Fake Report Output
```{R}
rpt_tbl<-ddply(params$DF, "Species", colwise(mean))
xtable(rpt_tbl)
```
More Fake Output
```{R}
pairs(params$DF[,c(1:4)])
```
I have scoured Stack Overflow and RStudio answers, but haven't found any that seem to be my problem. Part of me is wondering if this is a platform issue. Any help would be much appreciated. Thanks so much.
Take Care,
-Sean
After much searching and testing, I found out that the problem was not with tinytex or pdflatex, but rather my call to rmarkdown::render() That led me to this answer on GitHub https://github.com/rstudio/shiny/issues/1831. Apparently, when rmarkdown::render() is called within downloadHandler(), you should NOT specify the output_file argument in render() Instead you need to rename the file AFTER rendering.
Here is the correct code (simply replace the call to downloadHandler() in the script from my original question.
output$DWNLD<-downloadHandler(
filename=paste0(input$REPORT, ".pdf"),
content<-function(file){
RPT<-list(iris, airquality)
names(RPT)<-c("Iris", "AQ")
tmp <- file.path(tempdir(), "Reports.Rmd", fsep="\\")
file.copy("F:/Apps/DNR_TRIS/Shiny_report_scripts/SQL_SCRIPTS/Reports.Rmd", tmp, overwrite = TRUE)
out<-RPT[[input$REPORT]]
params<-list(out)
names(params)<-"DF"
out<-rmarkdown::render(tmp,
params = params,
envir = new.env(parent = globalenv()
))#End render
file.rename(out, file)
}
)

RMarkdown and knitting in Armenian

Thanks in advance for the help. I am trying to parametrically knit an RMD file into PDFs and HTMLs of different languages; one of them is Armenian. Knitting the Armenian version to any kind of format always produces literal UTF entities, like <U+0553><U+0578><U+0580><U+0571><U+0561><U+057C><U+0578>.
The .tex files are rendered as follows: \textless U+0553\textgreater\textless U+0578\textgreater\textless U+0580\textgreater\textless U+0571\textgreater
I have also tried using XeLaTeX and setting the main font to DejaVu Sans (i.e. latex_engine: xelatex and mainfont: DejaVu Sans), but it still knits the Armenian characters as Unicode literals.
I edited the XeTex .tex output and put in Armenian characters, and it worked fine. If Pandoc/RMD/Knitr didn't convert the characters to literals, then everything would work pefectly fine.
Even the .knit.md file already has the Unicode literals, so the problem is high up in the knitting chain, and I am not sure why this might be.
Any help would be appreciated.
Here's my minimal document (LuaLaTeX):
---
title: "Test Doc"
author: "Document"
output:
html_fragment:
section_divs: no
pdf_document:
latex_engine: lualatex
geometry: margin = 2cm
params:
lang: yes
lang: "`r switch(params$lang, CY = 'cy-GB', EN = 'en-GB', HY = 'hy-AM')`"
knit: (function(inputFile, encoding){ files <- c("cv-cy", "cv-en", "cv-hy"); langs <- c(list(lang = "CY"), list(lang = "EN"), list(lang = "HY")); i <- 1; for(f in files){ rmarkdown::render(inputFile, output_format = c("html_fragment", "pdf_document"), encoding = encoding, params = langs[i], output_file = c(paste0(dirname(inputFile), "/", print(f)), paste0(dirname(inputFile), "/", print(f)))); i <- i +1 } })
---
```
{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
lswitch <- function(lang, ...){
switch(lang, ..., stop(""))
}
```
`r lswitch(params$lang,
CY = "# Enw",
EN = "# Name",
HY = "# Անում"
)
`
Here's the pertinent section in the .log for the LuaLaTeX build:
) (d:/texlive/texmf-dist/tex/generic/babel/babel.sty
Package: babel 2019/05/04 3.31 The Babel package
(d:/texlive/texmf-dist/tex/generic/babel/switch.def
File: switch.def 2019/05/04 3.31 Babel switching mechanism
) (d:/texlive/texmf-dist/tex/generic/babel/luababel.def
\l#dumylang=\language2
Package babel Info: Non-standard hyphenation setup on input line 114.
\l#nohyphenation=\language3
\l#german-x-2019-04-04=\language4
\l#ngerman-x-2019-04-04=\language5
\l#afrikaans=\language6
\l#ancientgreek=\language7
\l#ibycus=\language8
\l#arabic=\language9
\l#armenian=\language10
\l#basque=\language11
\l#belarusian=\language12
\l#bulgarian=\language13
\l#catalan=\language14
\l#pinyin=\language15
\l#churchslavonic=\language16
\l#coptic=\language17
\l#croatian=\language18
\l#czech=\language19
\l#danish=\language20
\l#dutch=\language21
\l#ukenglish=\language22
\l#usenglishmax=\language23
\l#esperanto=\language24
\l#estonian=\language25
\l#ethiopic=\language26
\l#farsi=\language27
\l#finnish=\language28
\l#french=\language29
\l#friulan=\language30
\l#galician=\language31
\l#georgian=\language32
\l#german=\language33
\l#ngerman=\language34
\l#swissgerman=\language35
\l#monogreek=\language36
\l#greek=\language37
\l#hungarian=\language38
\l#icelandic=\language39
\l#assamese=\language40
\l#bengali=\language41
\l#gujarati=\language42
\l#hindi=\language43
\l#kannada=\language44
\l#malayalam=\language45
\l#marathi=\language46
\l#oriya=\language47
\l#panjabi=\language48
\l#pali=\language49
\l#tamil=\language50
\l#telugu=\language51
\l#indonesian=\language52
\l#interlingua=\language53
\l#irish=\language54
\l#italian=\language55
\l#kurmanji=\language56
\l#latin=\language57
\l#classiclatin=\language58
\l#liturgicallatin=\language59
\l#latvian=\language60
\l#lithuanian=\language61
\l#mongolian=\language62
\l#mongolianlmc=\language63
\l#bokmal=\language64
\l#nynorsk=\language65
\l#occitan=\language66
\l#piedmontese=\language67
\l#polish=\language68
\l#portuguese=\language69
\l#romanian=\language70
\l#romansh=\language71
\l#russian=\language72
\l#sanskrit=\language73
\l#serbian=\language74
\l#serbianc=\language75
\l#slovak=\language76
\l#slovenian=\language77
\l#spanish=\language78
\l#swedish=\language79
\l#thai=\language80
\l#turkish=\language81
\l#turkmen=\language82
\l#ukrainian=\language83
\l#uppersorbian=\language84
\l#welsh=\language85
)
! Package babel Error: Unknown option `armenian'. Either you misspelled it
(babel) or the language definition file armenian.ldf was not fou
nd.
See the babel package documentation for explanation.
Type H <return> for immediate help.
...
l.533 \ExecuteOptions{\bbl#opt#main}
Session info:
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363), RStudio 1.2.5019
Locale:
LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
LC_TIME=English_United Kingdom.1252
Package version:
base64enc_0.1.3 digest_0.6.23 evaluate_0.14 glue_1.3.1 graphics_3.6.1 grDevices_3.6.1 highr_0.8
htmltools_0.4.0 jsonlite_1.6 knitr_1.26 magrittr_1.5 markdown_1.1 methods_3.6.1 mime_0.7
Rcpp_1.0.3 rlang_0.4.2 rmarkdown_1.18 stats_3.6.1 stringi_1.4.3 stringr_1.4.0 tinytex_0.17
tools_3.6.1 utils_3.6.1 xfun_0.11 yaml_2.2.0
Pandoc version: 2.7.2

How to knitr beamer slides using Frankfurt theme without loosing navigation circles

After updating R and packages my beamer slides using Frankfurt theme no longer include the navigation circles at the top.
A mock Rmd file to demonstrate:
---
title: "Untitled"
output:
beamer_presentation:
theme: "Frankfurt"
# keep_tex: true
slide_level: 3
header-includes:
- \AtBeginSubsection{}
- \AtBeginSection{}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
# Intro
## .
### R Markdown
This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.
# Example
## .
### Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
### Slide with R Output
```{r cars, echo = TRUE}
summary(cars)
```
### Slide with Plot
```{r pressure}
plot(pressure)
```
Which gives ...
I can get the navigation circles to appear by setting keep_tex: true in the YAML and compiling the .tex file ...
... but this seems like an extra unnecessary step that was not previously required?
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] sessioninfo_1.1.1
loaded via a namespace (and not attached):
[1] compiler_3.6.1 assertthat_0.2.1 cli_1.1.0 htmltools_0.3.6 tools_3.6.1 withr_2.1.2
[7] rstudioapi_0.10 yaml_2.2.0 crayon_1.3.4 Rcpp_1.0.2 rmarkdown_1.15 knitr_1.25
[13] xfun_0.9 digest_0.6.20 packrat_0.5.0 evaluate_0.14
EDIT: As requested, the .tex file generated when setting keep_tex: true in the YAML
\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
ignorenonframetext,
]{beamer}
\usepackage{pgfpages}
\setbeamertemplate{caption}[numbered]
\setbeamertemplate{caption label separator}{: }
\setbeamercolor{caption name}{fg=normal text.fg}
\beamertemplatenavigationsymbolsempty
% Prevent slide breaks in the middle of a paragraph:
\widowpenalties 1 10000
\raggedbottom
\setbeamertemplate{part page}{
\centering
\begin{beamercolorbox}[sep=16pt,center]{part title}
\usebeamerfont{part title}\insertpart\par
\end{beamercolorbox}
}
\setbeamertemplate{section page}{
\centering
\begin{beamercolorbox}[sep=12pt,center]{part title}
\usebeamerfont{section title}\insertsection\par
\end{beamercolorbox}
}
\setbeamertemplate{subsection page}{
\centering
\begin{beamercolorbox}[sep=8pt,center]{part title}
\usebeamerfont{subsection title}\insertsubsection\par
\end{beamercolorbox}
}
\AtBeginPart{
\frame{\partpage}
}
\AtBeginSection{
\ifbibliography
\else
\frame{\sectionpage}
\fi
}
\AtBeginSubsection{
\frame{\subsectionpage}
}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provides euro and other symbols
\else % if luatex or xelatex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usetheme[]{Frankfurt}
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\#ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdftitle={Untitled},
pdfborder={0 0 0},
breaklinks=true}
\urlstyle{same} % don't use monospace font for urls
\newif\ifbibliography
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{248,248,248}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.94,0.16,0.16}{#1}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.77,0.63,0.00}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\BuiltInTok}[1]{#1}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.64,0.00,0.00}{\textbf{#1}}}
\newcommand{\ExtensionTok}[1]{#1}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ImportTok}[1]{#1}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{#1}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.81,0.36,0.00}{\textbf{#1}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\RegionMarkerTok}[1]{#1}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin#nat#width>\linewidth\linewidth\else\Gin#nat#width\fi}
\def\maxheight{\ifdim\Gin#nat#height>\textheight\textheight\else\Gin#nat#height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-2}
% set default figure placement to htbp
\makeatletter
\def\fps#figure{htbp}
\makeatother
\AtBeginSubsection{}
\AtBeginSection{}
\title{Untitled}
\date{}
\begin{document}
\frame{\titlepage}
\hypertarget{intro}{%
\section{Intro}\label{intro}}
\hypertarget{section}{%
\subsection{.}\label{section}}
\begin{frame}{R Markdown}
\protect\hypertarget{r-markdown}{}
This is an R Markdown presentation. Markdown is a simple formatting
syntax for authoring HTML, PDF, and MS Word documents. For more details
on using R Markdown see \url{http://rmarkdown.rstudio.com}.
When you click the \textbf{Knit} button a document will be generated
that includes both content as well as the output of any embedded R code
chunks within the document.
\end{frame}
\hypertarget{example}{%
\section{Example}\label{example}}
\hypertarget{section-1}{%
\subsection{.}\label{section-1}}
\begin{frame}{Slide with Bullets}
\protect\hypertarget{slide-with-bullets}{}
\begin{itemize}
\tightlist
\item
Bullet 1
\item
Bullet 2
\item
Bullet 3
\end{itemize}
\end{frame}
\begin{frame}[fragile]{Slide with R Output}
\protect\hypertarget{slide-with-r-output}{}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{summary}\NormalTok{(cars)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
\end{verbatim}
\end{frame}
\begin{frame}{Slide with Plot}
\protect\hypertarget{slide-with-plot}{}
\includegraphics{temp_files/figure-beamer/pressure-1.pdf}
\end{frame}
\end{document}

Error in eval(expr, envir, enclos) when sourcing files inside the R file

I have a problem of environment when I try to "knit HTML" or generate a pdf with LyX.
When I run directly the R code (or compile an HTML notebook with Rstudio), it's ok.
I have done the test with knitr#1.3.7 (dev version). I had not the problem with knit#1.2
On the sample given here after (test.Rhtml > test.R > init.R > kCommon.R), The returned error is :
Period: From
Error in eval(expr, envir, enclos) : objet 'kStartDate' introuvable
to
Error in eval(expr, envir, enclos) : objet 'kEndDate' introuvable
test.R
## #knitr INIT
source("./init.R")
print(kStartDate)
print(kEndDate)
test.R sources init.R
if (!require(xtable)){
install.packages("xtable")
library(xtable)
}
source("./kCommon.R")
init.R sources kCommon.R
# Period
kStartDate <- as.Date("2013-01-01", format="%Y-%m-%d")
kEndDate <- as.Date("2013-06-30", format="%Y-%m-%d")
test.Rhtml
<html>
<head>
<title>TEST</title>
</head>
<body>
<!--begin.rcode set-options, echo=FALSE
output <- "html"
read_chunk('test.R')
opts_chunk$set(fig.width=7, fig.height=4.5, fig.align='center', tidy=FALSE, comment=NA)
end.rcode-->
<!--begin.rcode INIT, echo=FALSE, message=FALSE, warning=FALSE
end.rcode-->
<p>
Period: From <!--rinline as.character(kStartDate) --> to <!--rinline as.character(kEndDate) -->
</p>
<hr/>
<p>
This document has been generated with <!--rinline version$version.string -->
on <!--rinline version$platform -->. <br/>
[<!--rinline date() -->]
</p>
<!--begin.rcode FIN, echo=FALSE, message=FALSE, warning=FALSE
end.rcode-->
</body>
</html>
Session info
> library(knitr);sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.3.7
loaded via a namespace (and not attached):
[1] digest_0.6.3 evaluate_0.4.6
formatR_0.9 stringr_0.6.2 tools_3.0.1
Results (after removing the options)
output <- "html"
read_chunk("test.R")
opts_chunk$set(fig.width = 7, fig.height = 4.5, fig.align = "center", tidy = FALSE,
comment = NA)
Period: From
Error in eval(expr, envir, enclos) : objet 'kStartDate' introuvable
to
Error in eval(expr, envir, enclos) : objet 'kEndDate' introuvable
This document has been generated with R version 3.0.1 (2013-05-16) on x86_64-apple-darwin10.8.0.
[Thu Aug 8 10:35:22 2013]
#EOF#
Log
> require(knitr); knit('test.Rhtml', encoding='UTF-8');
Le chargement a nécessité le package : knitr
processing file: test.Rhtml
|......... | 14%
ordinary text without R code
|................... | 29%
label: set-options
|............................ | 43%
ordinary text without R code
|..................................... | 57%
label: INIT
|.............................................. | 71%
inline R code fragments
Error in eval(expr, envir, enclos) : objet 'kStartDate' introuvable
Error in eval(expr, envir, enclos) : objet 'kEndDate' introuvable
|........................................................ | 86%
label: FIN
|.................................................................| 100%
ordinary text without R code
output file: test.html
[1] "test.html"
>
The example code you gave in test.R in the post was overly simplified, and the script you sent to me is actually this:
##-------
## #knitr INIT
##-------
source("./init.R")
print(kStartDate)
print(kEndDate)
That makes a difference, because of the new syntax for external code chunks (search for ---- in the NEWS). If you just want to fold code chunks in RStudio, see this question Code folding in external files with knitr and RStudio
one way to solve the issue is to clear knit cache pressing the button or setting this environment variable to FALSE, see it below:
{r setup, include=TRUE, cache = FALSE}
Cheers!

Resources