Context: I'm running some very big generalized additive models using mgcv. To avoid unnecessary recomputation and allow reproducibility I save the models to disk. Usually several models need to be fitted, a first one to extract autocorrelation (file1) and then a second one correcting for autocorrelation (file2). Below is a minimal example of my code.
if (!file.exists('file2')) {
if (!file.exists('file1')) {
writeLines('computing file 1')
1+1
}
writeLines('computing file 2')
1+1
}
which gives the following output
computing file 1
computing file 2
[1] 2
I noticed that some output of the inner if is missing, although writeLines, model computation and model saving happens, there is some diagnostic information which does not show up in the console/log file, much like the result of the 1+1 which does not show up. I tried rearranging the {} brackets onto single lines, and also to put sink(logfile.txt) [code] sink() around it, but that did not change anything. Any ideas what I'm doing wrong here?
Aucun commentaire:
Enregistrer un commentaire