Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- documentclass{article}
- usepackage{graphicx}
- begin{document}
- An Excel spreadsheet has been saved as textbf{dataandgraph.xlsx}.
- Now to get the data and the graphics into a PDF using LaTeX{}.
- section{Copy and Paste Methods}
- This approach is only useful for one-time graphics inclusions
- into LaTeX. And you are very, very sure that there will be
- no editing or changes of the graphics. (This is rarely true
- for Excel graphics.)
- subsection{Copy graphic, paste to PowerPoint, Save as *.png}
- This is quick and fairly easy to do. It is expecially useful
- if your workflow requires LaTeX{} for the paper and PowerPoint
- for the presentations.
- includegraphics[width=.45linewidth]{copypastetopptsaveaspng}
- subsection{Copy Data Table, paste to PowerPoint, Save as *.png}
- This is quick and fairly easy to do. It is expecially useful
- if your workflow requires LaTeX{} for the paper, Excel for
- data collection, and PowerPoint for the presentations.
- includegraphics[width=.45linewidth]{CopyDataToPPTsaveAspng}
- section{Using the textbf{R package xlsx} to read the
- textit{*.xlsx} file and Knitr to move to LaTeX{}}
- verb+http://www.sthda.com/english/wiki/+ \
- verb+r-xlsx-package-a-quick-start-guide-to-manipulate-excel-files-in-r+.
- Note: there is also a package textbf{openxlsx} which offers
- more control on writing and reading of xlsx files from R.
- subsection{Using R to move the data table to LaTeX{}}
- This requires that the computer has R installed with the
- needed R packages. And that the user knows how to integrate
- the knitr and LaTeX{} compile process.
- verb+http://yihui.name/knitr/+
- <<>>=
- library(xlsx)
- tt<- data.frame(read.xlsx('dataandgraph.xlsx',1))
- str(tt)
- tt
- @
- Using the Excel data to plot a graph.
- <<out.width='3in'>>=
- attach(tt)
- plot(a,b)
- @
- Now the data output can be made to use LaTeX{} fonts
- by xtable. Note: In the R-chunk all code output has
- been turned off.
- <<echo=FALSE,results='asis'>>=
- library(xtable)
- tt<- data.frame(read.xlsx('dataandgraph.xlsx',1))
- xtable(tt)
- @
- end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement