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}
4

1 回答 1

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

于 2015-04-13T09:37:00.917 回答