The most direct route is pictex(writefilename).
First, let's get some of the built-in data.
> data(presidents)
Then we set the output device, plot the data, and turn off the device.
> pictex("mytex.tex")
> plot(presidents)
> dev.off()
That file needs to be input into a properly formatted latex document. Make sure to include all of these packages:
\usepackage{graphicx}
\usepackage{pictex}
\usepackage{etex}
Put something like this in your document:
\begin{figure}[h!]
\center
\hspace{3ex}
\input{mytex.tex}
\end{figure}
Notice that \center does not work right for me here, so I'm forced to resort to some manual space manipulation. None of the various \begin{center} nor \centering seemed to help. Not yet sure why; notice below that \center works with \includegraphics{} and the .eps file; that might reflect on the different device outputs of R or it may just be the latex commands. (I would be exceedingly grateful to anyone who was willing to email me information concerning either the cause or the solution, potamite@usc.edu).
An eps can be output and imported as follows.
> postscript(file="myeps.eps", onefile=FALSE, horizontal=FALSE, width=4, height=4)
> plot(presidents)
> dev.off()
Now, you should be able to open the file independently (with mac's ps to pdf convertor), or you can include an eps in your latex like so:
\begin{figure}[h!]
\center
\includegraphics[width=.8\textwidth]{myeps.eps}
\end{figure}
Here, \center seems to work.
Be sure to include this package:
\usepackage{graphicx}
At first, I couldn't get jpgs to work, but try cutting and pasting (alt/opt-mouseclick) the following into your xterm window running R (notice that I finally left off the prompt symbol for more convenient cutting and pasting):
library(languageR)
dative.def=xtabs(~RealizationOfRecipient+DefinOfRec,data=dative)
dative.pron=xtabs(~RealizationOfRecipient+PronomOfRec,data=dative)
jpeg("datchi.jpg",width=400,height=420)
par(mfrow=c(1,2))
barplot(dative.def,beside=T,ylim=range(0,2500),legend=T)
barplot(dative.pron,beside=T,ylim=range(0,2500),legend=T)
dev.off()
Size specs seem important, also for including in latex,
can use absolute size (or not, see above),
but definitely need .jpg (not .jpeg not .JPEG, ... ?!?)!
\begin{figure}[h!]
\center
\includegraphics[width=120mm]{datchi.jpg}
\end{figure}
>x11()
>plot(presidents)
No need to bother with .off() here either.
Sometimes that's the simplest way to load a bunch of premade functions into R (as also recommended by Baayen).
BETTER YET: source('my-r-code')
(plus, everything seems to work fine through the terminal these days.)