4

I would like to use the tikz plotting device for my document. I compile a *.Rnw file from RStudio and I get an error message as soon as I set

dev='tikz'

The error

The error message is that

Error in createLockFile(lockname): cannot create lock file

This error is documented in conjunction with other issues (e.g. see here https://github.com/Sharpie/RTikZDevice/issues/66), but I found the issue here is unrelated to what is documented elsewhere.

A reproducible example:

Please find below a reproducible example:

\documentclass{scrartcl}

\usepackage{color,graphicx}
\usepackage{tikz}

<<setup, message=FALSE, cache=FALSE, echo=FALSE>>=
#Set your chunk options here
opts_chunk$set(fig.path='figure/graphics-', cache.path='cache/graphics-', fig.align='center', fig.width=13.69, fig.height=6.27, dev='tikz', fig.keep='last', cache=TRUE, par=TRUE, echo=FALSE, message=FALSE,     warning=FALSE, results= 'hide')
# Also load ggplot
library(ggplot2)
@

\begin{document}

\begin{figure}[h]
<<plot>>=
data <- data.frame(some.data = rnorm(10))
p1 <- ggplot(data, aes(x=1:10, y=some.data)) +  geom_point() + ylab(expression(X[t]))
p2 <- ggplot(data, aes(x=1:10, y=some.data)) +  geom_line() + ylab(expression(X[t]))
library(gridExtra)
grid.arrange(p1, p2, ncol=1)
@
\end{figure}

\end{document}    

and my session info is

R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

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

other attached packages:
[1] tikzDevice_0.7.0 filehash_2.2-2  

loaded via a namespace (and not attached):
[1] grid_3.0.2  tools_3.0.2

together with RStudio Version 0.98.501

The problem

The problem seems to occur when I want to arrange the ggplots p1 and p2 using the package gridExtra. I.e. when I plot the graphs individually without arranging them the code works, but it seems not to be able to handle the grid.arrange command. Is there any way to arrange plots such that tikz works?

Many thanks!

pfifas
  • 592
  • 4
  • 11
  • 1
    Cannot reproduce this in Rstudio running R 3.0.2 using tikzDevice_0.6.3, gridExtra_0.9.1, knitr_1.2, filehash_2.2-1, ggplot2_0.9.3.1. – fabians Mar 10 '14 at 17:03
  • @fabians are you using a Mac? I have a colleague who also was not able to reproduce and was using a Mac. Any hints what could cause the error? – pfifas Mar 10 '14 at 17:17
  • No, I'm on 64-bit Linux (Debian). Sorry, no idea. – fabians Mar 10 '14 at 17:20

0 Answers0