0

I had this piece of code that was working several months ago but not anymore now. I changed the directory but the data is the same.

My issue is that the cache is never saved. I tried different methods: either dep_prev(), dep_auto() + autodep or dependson and different debugging approaches but nothing seems to work. The computation is still performed at each run and there is nothing in the cache folder. Another issue that appeared is that my figures don´t appear anymore into my pdf file. They pop out when the R code is executed but they are not saved (the problem is probably linked to the cache problem).

In my code I setup everything in the first chunk then I don´t add any options in the following chunks. Here is the code of my first chunk:

<<setupKnitr, include=FALSE, cache=FALSE>>=
library(knitr)

## set global chunk options
opts_chunk$set(fig.path='figures_knitR/', cache.path='cache/', fig.align='center', fig.show='asis', par=TRUE, tidy = TRUE, cache = TRUE, autodep=T, fig.keep='all', dev='tikz', echo = TRUE, eval = TRUE)

opts_knit$set(output.dir = getwd())
dep_auto() 

options(formatR.arrow=TRUE, width=68, digits=4)
options(tikzDefaultEngine = 'pdftex')
@

Also I found something strange when looking at the dep_auto function: it uses the functions valid_path and parse_objects that are not known in my R session which might be the cause of the problem. And I cannot find the package from which they originates.

here is my sessionInfo

> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu precise (12.04.5 LTS)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] jerdev_0.1   knitr_1.10.5

loaded via a namespace (and not attached):
[1] tools_3.2.0 tcltk_3.2.0

Thank you very much for your help!

Bioninbo
  • 1
  • 1
  • 1
    Welcome to SO! Could you try to provide a minimal example of the problem? I.e. add a small document to the question where one graph (based on sample data) is generated. Others need to be able to reproduce your problem in order to help. – CL. Sep 03 '15 at 12:29
  • I am not sure about which document/graph I could upload. However I can give the kind of output that I get and an error message (among others): `> Sweave("reading_and_saving_data.Rnw") Writing to file reading_and_saving_data.tex Processing code chunks with options ... 1 : echo keep.source term verbatim (label = setupKnitr, reading_and_saving_data.Rnw:59) 4 : echo keep.source term verbatim (label = creation_of_the_count_and_countinfo_table, reading_and_saving_data.Rnw:165) ^C Warning messages: 1: In parse_objects(paths[1L]) : file cache/__objects not found 3: closing unused connection 4 () ` – Bioninbo Sep 03 '15 at 13:15
  • Take your code and remove everything that is not absolutely necessary to understand and reproduce your problem. Try to remove everything except for one or two chunks and test if it still behaves like you described in the question. Then, make sure the code is reproducible, i.e. don't use any external data sources but replace them by something from `data()`. See also [here](http://stackoverflow.com/a/5963610/2706569). – CL. Sep 03 '15 at 13:19
  • Btw, thank you for the welcome message! I will upload the code soon. – Bioninbo Sep 03 '15 at 13:27
  • Here is the code: http://www.filedropper.com/codeexample I use the command ¨ Sweave("code_example.Rnw") ¨ to call it within R from the directory where is the file. And I have created a ´cache´ and a ´figure_knitR folder in this current directory. – Bioninbo Sep 03 '15 at 13:50
  • Now I'm confused. Why do you use `Swave` instead of `knit` (and friends) if you want to use `knitr`? Maybe this is the reason why your code worked several months ago? The file you uploaded has some issues: It is not compiling and there aren't any plots. What I meant above was that you should use sample data to produce a plot in the same way as you *actually* produce your plots. Moreover, there is a slash missing in `cache.path`. This could explain your problems with caching. – CL. Sep 03 '15 at 14:51
  • Thanks for the answer, I´ll try that tomorrow at work! – Bioninbo Sep 03 '15 at 16:10
  • Hello, So as stupid as it seems, the answer to my problem was indeed to use the knit function instead of the Sweave funtion. I am not too sure which one I used several months ago. Anyway those issues are resolved now. Thank you very much for your help! – Bioninbo Sep 04 '15 at 13:33
  • You definitely didn't use Sweave with that document. :) Glad that your problem is solved. – CL. Sep 04 '15 at 13:34

0 Answers0