0

I am trying to create a PDF file (from Sweave .Rnw file in Rstudio).

When I run the code on its own, it seems to work:

library(ggplot2)
library(GGally)
ggparcoord(data.frame(mtcars), columns=1:6, alphaLines=0, boxplot=TRUE, scale="globalminmax") + coord_flip()

However, when I try to input this code into the .Rnw file, I get the code outputted, but the image is outputted. I am receiving no errors or warnings, as far as I know.

\documentclass{article}
\usepackage{float, hyperref}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{hyperref}

\begin{document}
\SweaveOpts{concordance=TRUE}

\author{myName}
\title{myTitle}

\maketitle

<<options, echo=FALSE>>=
library(knitr)
  opts_chunk$set(cache=TRUE)
@

\section*{Make ggparcoord plot in Sweave}

<<>>=
library(ggplot2)
library(GGally)
ggparcoord(data.frame(mtcars), columns=1:6, alphaLines=0, boxplot=TRUE, scale="globalminmax") + coord_flip()
@

\end{document}
  • Try wrapping the `ggparcoord` call into a `print()` statement. – Roman Luštrik Apr 13 '15 at 06:09
  • Thanks. I tried that, so that the line became print(ggparcoord(data.frame(mtcars), columns=1:6, alphaLines=0, boxplot=TRUE, scale="globalminmax") + coord_flip()), and it did not change anything in the output. –  Apr 13 '15 at 06:26

1 Answers1

0

This works for me.

\documentclass{article}
\usepackage{float}
\usepackage{hyperref}
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}

\begin{document}
\SweaveOpts{concordance=TRUE}

\author{myName}
\title{myTitle}

\maketitle

<<options, echo=FALSE>>=
library(knitr)
opts_chunk$set(cache=TRUE)
@

\section*{Make ggparcoord plot in Sweave}

<<fig = TRUE>>=
library(ggplot2)
library(GGally)
ggparcoord(data.frame(mtcars), columns=1:6, alphaLines=0, boxplot=TRUE, scale="globalminmax") + coord_flip()
@

\end{document}

Notice that I added a fig = TRUE argument into the Sweave chunk. I normally use knitr where such trivialities are handles automatically.

enter image description here

Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197