Advertisement
Guest User

Untitled

a guest
May 6th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. documentclass{article}
  2. usepackage{graphicx}
  3. begin{document}
  4. An Excel spreadsheet has been saved as textbf{dataandgraph.xlsx}.
  5. Now to get the data and the graphics into a PDF using LaTeX{}.
  6. section{Copy and Paste Methods}
  7. This approach is only useful for one-time graphics inclusions
  8. into LaTeX. And you are very, very sure that there will be
  9. no editing or changes of the graphics. (This is rarely true
  10. for Excel graphics.)
  11. subsection{Copy graphic, paste to PowerPoint, Save as *.png}
  12. This is quick and fairly easy to do. It is expecially useful
  13. if your workflow requires LaTeX{} for the paper and PowerPoint
  14. for the presentations.
  15.  
  16. includegraphics[width=.45linewidth]{copypastetopptsaveaspng}
  17. subsection{Copy Data Table, paste to PowerPoint, Save as *.png}
  18. This is quick and fairly easy to do. It is expecially useful
  19. if your workflow requires LaTeX{} for the paper, Excel for
  20. data collection, and PowerPoint for the presentations.
  21.  
  22. includegraphics[width=.45linewidth]{CopyDataToPPTsaveAspng}
  23.  
  24. section{Using the textbf{R package xlsx} to read the
  25. textit{*.xlsx} file and Knitr to move to LaTeX{}}
  26. verb+http://www.sthda.com/english/wiki/+ \
  27. verb+r-xlsx-package-a-quick-start-guide-to-manipulate-excel-files-in-r+.
  28.  
  29. Note: there is also a package textbf{openxlsx} which offers
  30. more control on writing and reading of xlsx files from R.
  31. subsection{Using R to move the data table to LaTeX{}}
  32. This requires that the computer has R installed with the
  33. needed R packages. And that the user knows how to integrate
  34. the knitr and LaTeX{} compile process.
  35. verb+http://yihui.name/knitr/+
  36. <<>>=
  37. library(xlsx)
  38. tt<- data.frame(read.xlsx('dataandgraph.xlsx',1))
  39. str(tt)
  40. tt
  41. @
  42. Using the Excel data to plot a graph.
  43. <<out.width='3in'>>=
  44. attach(tt)
  45. plot(a,b)
  46. @
  47.  
  48. Now the data output can be made to use LaTeX{} fonts
  49. by xtable. Note: In the R-chunk all code output has
  50. been turned off.
  51.  
  52. <<echo=FALSE,results='asis'>>=
  53. library(xtable)
  54. tt<- data.frame(read.xlsx('dataandgraph.xlsx',1))
  55. xtable(tt)
  56. @
  57.  
  58. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement