Well, I appear to have solved my own question. Not really sure as to the cause of problem but I will explain how I went about finding out wasn't working.
As usual in these situations I had to start by pairing down the code to the bare essentials, which was in this case left only the beamer template without the language packages.
I then added single code chunk with only a simple label name and the device <<nrone,dev='tikz'>>=
making sure I put the single quotes around the 'tikz'
.
I then gradually added the elements into the code chunk, beginning with importing the data.
When I imported the data I removed the rows with 2010-2012 in the histdata$Ar
column to simplify the plot and then gradually added in the missing data when I was sure it compiled.
While adding in the data I also added the extra settings to the ggplot line to group the data correctly, make the colour scheme black and white, and tilt the labels on the x-axis.
The plot was a bit big so I added in the out.width
setting to make it fit and put the cache=FALSE
to makesure it was refreshing the picture each time I compiled, as well as echo=FALSE,message=FALSE
to remove the extraneous text.
I then divided the code chunk in to two with the data import in one code chunk and the plotting of the data into the second as before.
Having gone through this process, I realised I didn't need the require(tikzDevice)
, which I had in before.
The corrected code is as follows:
\documentclass{beamer}
\usepackage[norsk]{babel}
\usepackage[utf8]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\mode<presentation>
{
\usetheme{Frankfurt}
% or ...
\setbeamercovered{transparent}
% or whatever (possibly just delete it)
}
\title[]{Title}
\subtitle{} % (optional)
\title{Title}
\author{JB}
\date{\today}
\if pdf
\pdfinfo {
/Author (JB)
/Title (Title)
/Subject ()
/Keywords ()
/CreationDate (D:20130531)
}
\fi
\begin{document}
\maketitle
% Hidden R code chunk --- reading in the data
<<setup, echo=FALSE,message=FALSE>>=
require(ggplot2)
histdata<-read.csv("data.csv")
histdata$Ar<-factor(histdata$Ar)
@
\begin{frame}
<<histogram,echo=FALSE,message=FALSE,dev='tikz',cache=FALSE,out.width='.8\\textwidth'>>=
ggplot(histdata,aes(x=Okt,y=Bes,fill=Ar)) + geom_bar(position="dodge",stat='identity') + scale_fill_grey(start=0.8, end=0) + theme(axis.text.x = element_text(angle=30, hjust=1, vjust=1))
@
\end{frame}
\end{document}
I hope this helps someone in a similar situation :-)