I've built a for loop to generate a series of PDF files automatically, but it says:
output file: test_chinese.knit.md
"C:/PROGRA~2/Pandoc/pandoc" +RTS -K512m -RTS test_chinese.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output 1TEST.tex --template "C:\Users\adminstor\Documents\R\win-library\3.4\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --pdf-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" --variable "compact-title:yes"
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (MiKTeX 2.9.6650 64-bit)
entering extended mode
! Argument of \CJK#XX has an extra }.
<inserted text>
\par
l.30 breaklinks=true}
Error: Failed to compile 1TEST.tex. See 1TEST.log for more info.
In addition: Warning messages:
1: running command '"pdflatex" -halt-on-error -interaction=batchmode "1TEST.tex"' had status 1
2: running command '"pdflatex" -halt-on-error -interaction=batchmode "1TEST.tex"' had status 1
Have to mention that: The .rmd file could run successfully without the for loop.
The for loop I built is:
for (i in 1:5){
cat(i, '\n')
rmarkdown::render("test_chinese.Rmd",
encoding = 'UTF-8',
params = list(file_number = i),
output_file = paste0(i, "TEST.pdf"),
output_format = 'pdf_document')
}
Since I'm generating a Chinese file, the TeX Template is CTeX Template with TinyTex.
Here is my sessionInfo():
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936 LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C LC_TIME=Chinese (Simplified)_China.936
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rvest_0.3.2 xml2_1.2.0 knitr_1.20 rmarkdown_1.10
loaded via a namespace (and not attached):
[1] Rcpp_0.12.16 magrittr_1.5 devtools_1.13.6 R6_2.2.2 stringr_1.3.1 httr_1.3.1 highr_0.6 tools_3.4.4
[9] xfun_0.3 tinytex_0.8 postr_0.0.0 git2r_0.23.0 withr_2.1.2 selectr_0.4-1 htmltools_0.3.6 yaml_2.2.0
[17] rprojroot_1.3-2 digest_0.6.15 rsconnect_0.8.8 curl_3.2 memoise_1.1.0 evaluate_0.11 stringi_1.1.7 compiler_3.4.4
[25] rticles_0.5 backports_1.1.2
Looking forward for your help!
Thanks everyone.
Related
I use sits in R on Windows 10 in order to receive satellite images from Amazon Web Services. It worked out already, but now I get this error message:
bfmn <- sits_cube(
source="AWS",
collection="SENTINEL-S2-L2A",
dir="C:/temp/final2",
bands = c("B02","B03","B04","B05","B08","B11","B12","SCL"),
start_date = "2019-03-01",
end_date = "2019-06-04",
roi=AOI,
delim = "_",
multicores = 2,
progress = TRUE)
Error: sits_cube: AWS_ACCESS_KEY_ID: Missing access token for source AWS (nzchar(Sys.getenv(x)) is not TRUE)
What do I set as AWS_ACCESS_KEY_ID? Does this I mean I have to log in in order to able to use the service?
Thanks
> sessionInfo()
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.utf8 LC_CTYPE=German_Germany.utf8 LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C LC_TIME=German_Germany.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RPostgres_1.4.4
loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 lattice_0.20-45 here_1.0.1 png_0.1-8 withr_2.5.0 rprojroot_2.0.3 rappdirs_0.3.3 grid_4.2.2 lifecycle_1.0.3
[10] jsonlite_1.8.4 DBI_1.1.3 rlang_1.0.6 cli_3.4.1 rstudioapi_0.14 blob_1.2.3 Matrix_1.5-1 ellipsis_0.3.2 vctrs_0.5.1
[19] reticulate_1.27 tools_4.2.2 bit64_4.0.5 bit_4.0.5 hms_1.1.2 compiler_4.2.2 pkgconfig_2.0.3
it seems to me that your function is trying to access the environment variable AWS_ACCESS_KEY_ID.
double check that you have that value set using echo $AWS_ACCESS_KEY_ID for Linux/mac
I use the kableExtra package all the time to create tables in R Markdown and save them to PDF. However today I upgraded to MacOS Catalina and now when I export to PDF, I cannot open the PDF image and get the error, "insufficient data for an image" in Adobe Reader. I don't get an error message in R Markdown and the PDF appears in my files, but I cannot open it in Adobe. If I use another application to open it (i.e., Preview) the resolution is very poor - and not typical of PDF. Has anyone else run into this problem and is there a solution? Many thanks for your help!
My code to retrieve the error is below:
mtcars %>%
kable() %>%
kable_styling() %>%
save_kable("test.pdf")
And session info is:
R version 3.6.2 (2019-12-12)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.4
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] metafor_2.1-0 Matrix_1.2-18 MASS_7.3-51.5 RColorBrewer_1.1-2 tidyr_1.0.2 knitr_1.28
[7] sandwich_2.5-1 plotROC_2.2.1 ggROC_1.0 pROC_1.16.1 dplyr_0.8.4 plyr_1.8.5
[13] foreign_0.8-75 gridExtra_2.3 kableExtra_1.1.0 scales_1.1.0 ggplot2_3.2.1 psych_1.9.12.31
loaded via a namespace (and not attached):
[1] Rcpp_1.0.3 lattice_0.20-38 ps_1.3.2 zoo_1.8-7 utf8_1.1.4 assertthat_0.2.1
[7] digest_0.6.24 R6_2.4.1 evaluate_0.14 httr_1.4.1 highr_0.8 pillar_1.4.3
[13] rlang_0.4.4 lazyeval_0.2.2 rstudioapi_0.11 callr_3.4.2 magick_2.3 rmarkdown_2.1
[19] labeling_0.3 webshot_0.5.2 readr_1.3.1 stringr_1.4.0 munsell_0.5.0 compiler_3.6.2
[25] xfun_0.12 pkgconfig_2.0.3 mnormt_1.5-6 htmltools_0.4.0 tidyselect_1.0.0 tibble_2.1.3
[31] fansi_0.4.1 viridisLite_0.3.0 crayon_1.3.4 withr_2.1.2 grid_3.6.2 nlme_3.1-144
[37] jsonlite_1.6.1 gtable_0.3.0 lifecycle_0.1.0 magrittr_1.5 cli_2.0.1 stringi_1.4.6
[43] farver_2.0.3 xml2_1.2.2 vctrs_0.2.2 tools_3.6.2 glue_1.3.1 purrr_0.3.3
[49] hms_0.5.3 processx_3.4.2 parallel_3.6.2 yaml_2.2.1 colorspace_1.4-1 rvest_0.3.5
New to Rmarkdown (and markdown in general). I've inherited some code that works great for the html_document output format but not for pdf_document. It seems to get stuck on the knitr asis_output function in the .Rmd script. When I comment out chunks containing that function, it writes to pdf no problem. Here's some troubleshooting I've tried:
xfun::session_info('rmarkdown')
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.1, RStudio 1.2.1335
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
Locale: en_CA.UTF-8 / en_CA.UTF-8 / en_CA.UTF-8 / C / en_CA.UTF-8 / en_CA.UTF-8
:Package version:
base64enc_0.1.3 digest_0.6.20 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.25 magrittr_1.5 markdown_1.1 methods_3.6.1 mime_0.7
Rcpp_1.0.2 rlang_0.4.0 rmarkdown_1.16 stats_3.6.1 stringi_1.4.3 stringr_1.4.0 tinytex_0.17.1
tools_3.6.1 utils_3.6.1 xfun_0.10 yaml_2.2.0
Pandoc version: 2.7.3
Sys.getenv('PATH')
[1] "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/opt/X11/bin"
tinytex::tinytex_root()
[1] "/usr/local/texlive/2019"
(tinytex::tlmgr_path())
tlmgr path add add_link_dir_dir: /usr/local/share/info/dir exists;
not making symlink. add_link_dir_dir: destination
/usr/local/share/man/man5 not writable, no links from
/usr/local/texlive/2019/texmf-dist/doc/man/man5.tlmgr: An error has
occurred. See above messages. Exiting. add of symlinks had 1
error(s), see messages above.[1] 6
So maybe the problem is a path issue? In which case I have no clue how to fix. Or should I be using an alternative to the asis_output function? Any help is much appreciated. Here's the relevant bits of my code:
In the R script:
id <- 44
rmarkdown::render('mymarkdown.Rmd',
output_format = "pdf_document",
output_file = paste("report_", id,".pdf", sep=''),
output_dir = '/Users/myname/Documents/test')
In the Rmd file:
---
title: "Monitoring Activity Summary Report"
mode: selfcontained
date: "November 2019"
output:
pdf_document: default
html_document: default
self_contained: yes
---
[some code chunks...]
[then these code chunks that get stuck only for "pdf_document"...]
``` {r setup_Samp1a, echo=FALSE}
sampling_1 <- !is.na(sampling_unique[1])```
```{r conditional block, eval = sampling_1}
asis_output("### 3.1 Sampling 1\\n") # Header that is only shown if
sampling_1 == TRUE```
The error message
! Undefined control sequence.
<argument> 3.1 Sampling 1\n
Error: Failed to compile /Users/myname/Documents/test/report_44.tex.
See https://yihui.name/tinytex/r/#debugging for debugging tips. See
report_44.log for more info.
When knitting an Rmarkdown document to Powerpoint, I do not understand why by default the inline code (or chunks code) is rendered in the presentation in font Courier size 18pt, whereas the rest of the non-code text is in font Calibri size 28pt.
I could only change the later using a custom template, but not the code appearance. Did I miss something?
Here is a simple example:
---
title: "Untitled"
author: "Julien Roux"
date: "9/18/2019"
output:
powerpoint_presentation: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## R Markdown
Why is `inline code` appearing smaller?
Which results in this output slide after knitting in Rstudio (version 1.2.1578):
My session info:
> sessionInfo()
R version 3.6.0 Patched (2019-05-14 r76503)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.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
loaded via a namespace (and not attached):
[1] compiler_3.6.0 htmltools_0.3.6 tools_3.6.0 yaml_2.2.0 Rcpp_1.0.2 rmarkdown_1.15 knitr_1.24
[8] xfun_0.9 digest_0.6.20 evaluate_0.14
I'm automating a pdf report using rmarkdown. I use a macro to run the code. I can run the code once and it works with no problems. When I call the macro again, it appears to work but when creating a pdf, I get the error "LaTeX Error: Missing \begin{document}"
This is what I get the first time:
output file: L:/Statunit/morton/NCC R markdown reports/NCC Reports/NCC_Dashboard_Report_Dave.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS "L:/Statunit/morton/NCC R markdown reports/NCC Reports/NCC_Dashboard_Report_Dave.utf8.md" --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pandoc9e03c3032cf.tex --template "C:\Users\Mortond\Documents\R\win-library\3.5\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine xelatex --variable graphics=yes --variable "geometry:margin=1in" --variable "compact-title:yes" --include-in-header "C:\Users\Mortond\AppData\Local\Temp\Rtmp8cWvvQ\rmarkdown-str9e022b75c22.html"
Output created: Report-254-225573.pdf
The second time, I call the same code but only change the report name, so the data is the same and I get.
output file: L:/Statunit/morton/NCC R markdown reports/NCC Reports/NCC_Dashboard_Report_Dave.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS "L:/Statunit/morton/NCC R markdown reports/NCC Reports/NCC_Dashboard_Report_Dave.utf8.md" --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pandoc9e01f0a74c5.tex --template "C:\Users\Mortond\Documents\R\win-library\3.5\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine xelatex --variable graphics=yes --variable "geometry:margin=1in" --variable "compact-title:yes"
! LaTeX Error: Missing \begin{document}.
Error: Failed to compile Report-253-225573.tex. See Report-253-225573.log for more info.
my YAML is
---
title: ''
header-includes:
- \usepackage{fancyhdr}
- \addtolength{\headheight}{1.0cm} % make more space for the header
- \pagestyle{fancyplain} % use fancy for all pages except chapter start
- \lhead{\includegraphics[height=1.2cm]{TJC_logo_color.png}} % left logo
- \renewcommand{\headrulewidth}{0pt} % remove rule below header
output:
pdf_document:
latex_engine: xelatex
word_document: default
html_document: default
urlcolor: blue
classoption: landscape
---
my code that calls the markdown is :
render_report = function(b,h,p) {
rmarkdown::render(
"L:/Statunit/morton/NCC R markdown reports/NCC Dashboard Report
Dave.Rmd", params = list(
b1 = b,
h1 = h,
p1 = p
),
output_file = paste0("Report-", h, "-", p, ".pdf")
)
}
render_report(b="xxxx Hospital, Inc.",h='253',p='225573')
The log file with the error part is.
("C:\Users\Mortond\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics-def\xet
ex.def"
File: xetex.def 2017/06/24 v5.0h Graphics/color driver for xetex
))
\Gin#req#height=\dimen160
\Gin#req#width=\dimen161
)
("C:\Users\Mortond\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\grffile
.sty"
Package: grffile 2017/06/30 v1.18 Extended file name support for graphics (HO)
Package grffile Info: Option `multidot' is set to `true'.
Package grffile Info: Option `extendedchars' is set to `false'.
Package grffile Info: Option `space' is set to `true'.
Package grffile Info: \Gin#ii of package `graphicx' fixed on input line 494.
)
("C:\Users\Mortond\AppData\Local\Programs\MiKTeX 2.9\tex\latex\parskip\parskip.
sty"
Package: parskip 2018-08-24 v2.0a non-zero parskip adjustments
)
("C:\Users\Mortond\AppData\Local\Programs\MiKTeX 2.9\tex\latex\titling\titling.
sty"
Package: titling 2009/09/04 v2.1d maketitle typesetting
\thanksmarkwidth=\skip53
\thanksmargin=\skip54
\droptitle=\skip55
)
("C:\Users\Mortond\AppData\Local\Programs\MiKTeX 2.9\tex\latex\fancyhdr\fancyhd
r.sty"
Package: fancyhdr 2017/06/30 v3.9a Extensive control of page headers and footer
s
\f#nch#headwidth=\skip56
\f#nch#O#elh=\skip57
\f#nch#O#erh=\skip58
\f#nch#O#olh=\skip59
\f#nch#O#orh=\skip60
\f#nch#O#elf=\skip61
\f#nch#O#erf=\skip62
\f#nch#O#olf=\skip63
\f#nch#O#orf=\skip64
)
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.90 \addtolength{\headheight}{1.0cm} \%
make more space for the header
Here is how much of TeX's memory you used:
22493 strings out of 427767
408844 string characters out of 3146884
530389 words of memory out of 3000000
26423 multiletter control sequences out of 15000+200000
532722 words of font info for 28 fonts, out of 3000000 for 9000
1328 hyphenation exceptions out of 8191
45i,0n,68p,816b,443s stack positions out of 5000i,500n,10000p,200000b,50000s
No pages of output.
So why does it work once and not a second time? If I exit RStudio and then s start it up again, it appears to work. I've tried to
.rs.restartR() to no avail. as well as
rm(list = ls(envir = globalenv()),envir = globalenv())
gc() to clean things up.
Any thoughts? I appreciate reading through all this.
I do not know if I had the same issue. But I experienced that if I compiled my document it worked the first time and failed the second. I suspected a cache issue and added cache.rebuild=T to
<<echo=F, cache=T, message=F, warning=F, `>>=
set_parent('../../Parent.Rnw')
#
Just FIY, the header of the parent does not only include the latex info but also sources my main .R file with the calculations.
Anyway, if someone experience a similar problem try to add cache.rebuild=T to your included script(s).