Post

1 follower Follow
0
Avatar

ENTIRE pc freezes when rmarkdown::render is called in loop (...upon 6th iteration)

I have 13 reports that I wish to produce based on a template .rmd file. To achieve this I've constructed a loop with a counter grabbing specific aspects of a dataframe to populate the template with for each report.

I can succesfully loop through the code 5 times and html files are created, but on the 6th iteration, my entire machine freezes and requires a hard reboot for me to regain control.

I've envoked the following commands to attempt to "solve" the problem at each iteration of the loop, but this does not seem to work :

Sys.unsetenv("LC_ALL")

Sys.unsetenv("LANG")

I've read that people are experiencing problems with pandoc, but their symptoms don't quite agree with mine, since I loose complete control over my pc - not merely my RStudio IDE (everything freezes).

I've run this process with a "brand, new, clean" .rmd file (as template), placing it in a loop and calling it with the following command :

i = 1
while(i <= 13){

rmarkdown::render("d:/template.rmd", output_format = c("html_document"), output_file = "d:/out.html")

i = i + 1

}

...and my entire pc crashes on the 6th iteration. The current while loop is used with different criteria in my actual program, but this illustrates my basic script layout.

_________________

 

sessionInfo():

R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_South Africa.1252 LC_CTYPE=English_South Africa.1252 LC_MONETARY=English_South Africa.1252 LC_NUMERIC=C
[5] LC_TIME=English_South Africa.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] kableExtra_0.7.0 sqldf_0.4-11 RSQLite_2.0 gsubfn_0.6-6 proto_1.0.0 RPostgreSQL_0.6-2 DBI_0.7 markdown_0.8 knitr_1.19
[10] rmarkdown_1.8

loaded via a namespace (and not attached):
[1] Rcpp_0.12.14 xml2_1.1.1 magrittr_1.5 hms_0.4.1 munsell_0.4.3 rvest_0.3.2 bit_1.1-12 viridisLite_0.2.0 colorspace_1.3-2
[10] R6_2.2.2 rlang_0.1.4 plyr_1.8.4 httr_1.3.1 stringr_1.2.0 blob_1.1.0 tcltk_3.4.2 tools_3.4.2 htmltools_0.3.6
[19] yaml_2.1.16 bit64_0.9-7 rprojroot_1.3-2 digest_0.6.12 tibble_1.3.4 readr_1.1.1 memoise_1.1.0 evaluate_0.10.1 stringi_1.1.6
[28] compiler_3.4.2 scales_0.5.0 backports_1.1.1 lubridate_1.7.1 chron_2.3-51 pkgconfig_2.0.1

Corne de Witt