74

I am operating matrices with R 3.1 and RStudio 0.99.

I have my R Script and with cmd+enter it works without problem.

I created an Rmd for reporting but I have this error

Error in lazyLoadDBinsertVariable(vars[i], from, datafile, ascii, compress,  : 
  long vectors not supported yet: ../../../../R-3.3.1/src/main/connections.c:5600
Calls: <Anonymous> ... <Anonymous> -> <Anonymous> -> lazyLoadDBinsertVariable
Execution halted

Is there a way to bypass that error?

This seems to be a dupicate of Large Matrices in R: long vectors not supported yet

but the difference is that this only happens when trying to create an Rmd, not in any other case

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
pachadotdev
  • 3,345
  • 6
  • 33
  • 60

2 Answers2

105

I also ran into this today, and fixed it by using cache.lazy = FALSE in the setup chunk in my .Rmd.

So what is inside of the first chunk in my R Markdown file looks like this:

library(knitr)
knitr::opts_chunk$set(cache = TRUE, warning = FALSE, 
                      message = FALSE, cache.lazy = FALSE)
Aurélien Gasser
  • 3,043
  • 1
  • 20
  • 25
Julia Silge
  • 10,848
  • 2
  • 40
  • 48
  • This is the right answer. I just wanted to add that for whatever reason, I had to access it from `options` instead of `opts_chunk$set`. So I had `options(cache = TRUE, warning = FALSE, message = FALSE, cache.lazy = FALSE)`. I'm on RStudio 3.2.2 if that makes any difference – Nicholas Hassan Apr 18 '18 at 17:08
  • This is probably sue if you are caching a very big R object. That was my problem. – Bastien May 17 '18 at 13:12
  • Using the original answer with `knitr::opts_chunk$set` worked for me on R 3.5.1. – Carmen Sandoval Aug 31 '18 at 18:48
  • 3
    For more background read https://bookdown.org/yihui/rmarkdown-cookbook/cache-lazy.html – MartineJ Sep 21 '20 at 08:45
9

I am getting the same error in my .rmd file while trying to knit it to pdf. The incriminated code chunk was cached.

Is there a way to bypass that error?

Removing the 'cache = TRUE' or setting it to FALSE seems to fix the issue.

D-Lorenz
  • 176
  • 1
  • 6
  • 2
    This does not provide an answer to the question. Once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](http://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/14017730) – etienne Oct 18 '16 at 10:58
  • Hi. I wasn't caching. I cached now and it happens with or without caching. A possible solution was already commented. – pachadotdev Oct 19 '16 at 00:20
  • 1
    Thank @etienne for the clarification. I don't get why I am being downvoted because the solution I suggest actually fixed the problem for my script. – D-Lorenz Oct 19 '16 at 13:14