Document Classesexamdesign | Graphs from Sweave in RStudio

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
sjkiss
Posts: 30
Joined: Tue Nov 15, 2011 12:23 am

examdesign | Graphs from Sweave in RStudio

Post by sjkiss »

HI: I'm using TexShop on mac os 10.6, R, RStudio, Sweave and latex to produce my documents.

I need to create an exam using examdesign but am having trouble creating graphs in my code. The following code works fine, using \includegraphics to take a pre-made graph.

But I'd like to draw the graph within the sweave document. The code I'd *like* to use follows further before.

Thank you! Simon Kiss

Code: Select all

\documentclass[letter]{examdesign}
\class{OL344 - Social Science Research Methods 2 (Survey Research)}
\begin{document}
\begin{shortanswer}[title={Short answer questions}]
\begin{block} 
\includegraphics{/Users/simon/Documents/fluoridation/summary/fluoride-006.pdf}
\begin{question}
What is the relationship between the mean, median and mode when data are normally distributed?
\end{question}
\end{block}
\end{shortanswer}
\end{document}

Code: Select all

\documentclass[letter]{examdesign}
\class{OL344 - Social Science Research Methods 2 (Survey Research)}


\begin{document}

\begin{shortanswer}[title={Short answer questions}]
\begin{block} 

<<fig=true, eval=true, include=true>>=
barplot(matrix(c(50,50,50, 50), nrow=2, dimnames=list(Gender=c('Male', 'Female'), Voted=c('Did Not Vote', 'Voted'))))
@
                                                                                          
\begin{question}
What is the relationship between the mean, median and mode when data are normally distributed?
  \end{question}
\end{block}
\end{shortanswer}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply