I can't get the R package tikzDevice
to running. I installed MiKTex and I don't have problems to produce documents like this one via TeXworks.
Exporting plots via tikzDevice unfortunately doesn't work, for example the following code from here produces an error message:
library(tikzDevice)
library(ggplot2)
#For some reason, Rstudio needs to know the time zone...
options(tz="CA")
#Dummy data for the plot
y <- exp(seq(1,10,.1))
x <- 1:length(y)
data <- data.frame(x = x, y = y)
#Create a .tex file that will contain your plot as vectors
#You need to set the size of your plot here, if you do it in LaTeX,
#font consistency with the rest of the document will be lost
tikz(file = "plot_test.tex", width = 5, height = 5)
#Simple plot of the dummy data using LaTeX elements
plot <- ggplot(data, aes(x = x, y = y)) +
geom_line() +
#Space does not appear after Latex
ggtitle( paste("Fancy \\LaTeX ", "\\hspace{0.01cm} title")) +
labs( x = "$x$ = Time", y = "$\\Phi$ = Innovation output") +
theme_bw()
#This line is only necessary if you want to preview the plot right after compiling
print(plot)
#Necessary to close or the tikxDevice .tex file will not be written
dev.off()
The following error message is produced:
Measuring dimensions of: \char77
Error in get_latex_cmd(TeXMetrics$engine) :
Cannot find LaTeX! Please check your system configuration or manually provide a value for options(tikzLatex)
I couldn't find a discussion about that problem on Google or here so I would appreciate some help.