rorg.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml"
  4. lang="en" xml:lang="en">
  5. <head>
  6. <title>rorg &mdash; R and org-mode</title>
  7. <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
  8. <meta name="generator" content="Org-mode"/>
  9. <meta name="generated" content="2009-02-05 21:16:20 EST"/>
  10. <meta name="author" content="Dan"/>
  11. <style type="text/css">
  12. <!--/*--><![CDATA[/*><!--*/
  13. html { font-family: Times, serif; font-size: 12pt; }
  14. .title { text-align: center; }
  15. .todo { color: red; }
  16. .done { color: green; }
  17. .tag { background-color:lightblue; font-weight:normal }
  18. .target { }
  19. .timestamp { color: grey }
  20. .timestamp-kwd { color: CadetBlue }
  21. p.verse { margin-left: 3% }
  22. pre {
  23. border: 1pt solid #AEBDCC;
  24. background-color: #F3F5F7;
  25. padding: 5pt;
  26. font-family: courier, monospace;
  27. font-size: 90%;
  28. overflow:auto;
  29. }
  30. table { border-collapse: collapse; }
  31. td, th { vertical-align: top; }
  32. dt { font-weight: bold; }
  33. div.figure { padding: 0.5em; }
  34. div.figure p { text-align: center; }
  35. .linenr { font-size:smaller }
  36. .code-highlighted {background-color:#ffff00;}
  37. .org-info-js_info-navigation { border-style:none; }
  38. #org-info-js_console-label { font-size:10px; font-weight:bold;
  39. white-space:nowrap; }
  40. .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
  41. font-weight:bold; }
  42. /*]]>*/-->
  43. </style>
  44. <script type="text/javascript">
  45. <!--/*--><![CDATA[/*><!--*/
  46. function CodeHighlightOn(elem, id)
  47. {
  48. var target = document.getElementById(id);
  49. if(null != target) {
  50. elem.cacheClassElem = elem.className;
  51. elem.cacheClassTarget = target.className;
  52. target.className = "code-highlighted";
  53. elem.className = "code-highlighted";
  54. }
  55. }
  56. function CodeHighlightOff(elem, id)
  57. {
  58. var target = document.getElementById(id);
  59. if(elem.cacheClassElem)
  60. elem.className = elem.cacheClassElem;
  61. if(elem.cacheClassTarget)
  62. target.className = elem.cacheClassTarget;
  63. }
  64. /*]]>*/-->
  65. </script>
  66. </head><body>
  67. <h1 class="title">rorg &mdash; R and org-mode</h1>
  68. <div id="table-of-contents">
  69. <h2>Table of Contents</h2>
  70. <div id="text-table-of-contents">
  71. <ul>
  72. <li><a href="#sec-1">1 Objectives </a>
  73. <ul>
  74. <li><a href="#sec-1.1">1.1 Send data to R from org </a>
  75. <ul>
  76. <li><a href="#sec-1.1.1">1.1.1 Implementations </a></li>
  77. </ul>
  78. </li>
  79. <li><a href="#sec-1.2">1.2 evaluate R code from org and deal with output appropriately </a>
  80. <ul>
  81. <li><a href="#sec-1.2.1">1.2.1 vector output </a></li>
  82. <li><a href="#sec-1.2.2">1.2.2 graphical output </a></li>
  83. </ul></li>
  84. </ul>
  85. </li>
  86. <li><a href="#sec-2">2 Notes </a>
  87. <ul>
  88. <li><a href="#sec-2.1">2.1 Special editing and evaluation of source code in R blocks </a>
  89. <ul>
  90. <li><a href="#sec-2.1.1">2.1.1 Source code blocks </a></li>
  91. <li><a href="#sec-2.1.2">2.1.2 dblocks </a></li>
  92. <li><a href="#sec-2.1.3">2.1.3 R blocks </a></li>
  93. </ul></li>
  94. </ul>
  95. </li>
  96. <li><a href="#sec-3">3 tasks </a></li>
  97. <li><a href="#sec-4">4 buffer dictionary </a></li>
  98. </ul>
  99. </div>
  100. </div>
  101. <div id="outline-container-1" class="outline-2">
  102. <h2 id="sec-1">1 Objectives </h2>
  103. <div id="text-1">
  104. </div>
  105. <div id="outline-container-1.1" class="outline-3">
  106. <h3 id="sec-1.1">1.1 Send data to R from org </h3>
  107. <div id="text-1.1">
  108. <p>Org-mode includes orgtbl-mode, an extremely convenient way of using
  109. tabular data in a plain text file. Currently, spreadsheet
  110. functionality is available in org tables using the emacs package
  111. calc. It would be a boon both to org users and R users to allow
  112. org tables to be manipulated with the R programming language. Org
  113. tables give R users an easy way to enter and display data; R gives
  114. org users a powerful way to perform vector operations, statistical
  115. tests, and visualization on their tables.
  116. </p>
  117. </div>
  118. <div id="outline-container-1.1.1" class="outline-4">
  119. <h4 id="sec-1.1.1">1.1.1 Implementations </h4>
  120. <div id="text-1.1.1">
  121. <ul>
  122. <li id="sec-1.1.1.1">naive <br/>
  123. Naive implementation would be to use <code>(org-export-table "tmp.csv")</code>
  124. and <code>(ess-execute "read.csv('tmp.csv')")</code>.
  125. </li>
  126. <li id="sec-1.1.1.2">org-R <br/>
  127. org-R passes data to R from two sources: org tables, or csv
  128. files. Org tables are first exported to a temporary csv file
  129. using <a href="existing_tools/org-R.el">org-R-export-to-csv</a>.
  130. </li>
  131. <li id="sec-1.1.1.3">org-exp-blocks <br/>
  132. </li>
  133. <li id="sec-1.1.1.4">RweaveOrg <br/>
  134. NA
  135. </li>
  136. </ul>
  137. </div>
  138. </div>
  139. </div>
  140. <div id="outline-container-1.2" class="outline-3">
  141. <h3 id="sec-1.2">1.2 evaluate R code from org and deal with output appropriately </h3>
  142. <div id="text-1.2">
  143. </div>
  144. <div id="outline-container-1.2.1" class="outline-4">
  145. <h4 id="sec-1.2.1">1.2.1 vector output </h4>
  146. <div id="text-1.2.1">
  147. <p>When R code evaluation generates vectors and 2-dimensional arrays,
  148. this should be formatted appropriately in org buffers (orgtbl-mode) as well
  149. as in export targets (html, latex)
  150. </p><ul>
  151. <li id="sec-1.2.1.1">Implementations <br/>
  152. <ul>
  153. <li id="sec-1.2.1.1.1">org-R <br/>
  154. org-R converts R output (vectors, or matrices / 2d-arrays) to an
  155. org table and stores it in the org buffer, or in a separate org
  156. file (csv output would also be perfectly possible).
  157. </li>
  158. <li id="sec-1.2.1.1.2">org-exp-blocks <br/>
  159. </li>
  160. <li id="sec-1.2.1.1.3">RweaveOrg <br/>
  161. </li>
  162. </ul>
  163. </li>
  164. </ul>
  165. </div>
  166. </div>
  167. <div id="outline-container-1.2.2" class="outline-4">
  168. <h4 id="sec-1.2.2">1.2.2 graphical output </h4>
  169. <div id="text-1.2.2">
  170. <p>R can generate graphical output on a screen graphics device
  171. (e.g. X11, quartz), and in various standard image file formats
  172. (png, jpg, ps, pdf, etc). When graphical output is generated by
  173. evaluation of R code in Org, at least the following two things are desirable:
  174. </p><ol>
  175. <li>
  176. output to screen for immediate viewing is possible
  177. </li>
  178. <li>
  179. graphical output to file is linked to appropriately from the
  180. org file This should have the automatic consequence that it is
  181. included appropriately in subsequent export targets (html,
  182. latex).
  183. </li>
  184. </ol>
  185. <ul>
  186. <li id="sec-1.2.2.1">Implementations <br/>
  187. <ul>
  188. <li id="sec-1.2.2.1.1">org-R <br/>
  189. org-R does (1) if no output file is specified and (2) otherwise
  190. </li>
  191. <li id="sec-1.2.2.1.2">org-exp-blocks <br/>
  192. </li>
  193. <li id="sec-1.2.2.1.3">RweaveOrg <br/>
  194. </li>
  195. </ul>
  196. </li>
  197. </ul>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <div id="outline-container-2" class="outline-2">
  203. <h2 id="sec-2">2 Notes </h2>
  204. <div id="text-2">
  205. </div>
  206. <div id="outline-container-2.1" class="outline-3">
  207. <h3 id="sec-2.1">2.1 Special editing and evaluation of source code in R blocks </h3>
  208. <div id="text-2.1">
  209. <p>Unfortunately org-mode how two different block types, both useful.
  210. In developing RweaveOrg, a third was introduced.
  211. </p>
  212. <p>
  213. Eric is leaning towards using the <code>#+begin_src</code> blocks, as that is
  214. really what these blocks contain: source code. Austin believes
  215. that specifying export options at the beginning of a block is
  216. useful functionality, to be preserved if possible.
  217. </p>
  218. <p>
  219. Note that upper and lower case are not relevant in block headings.
  220. </p>
  221. </div>
  222. <div id="outline-container-2.1.1" class="outline-4">
  223. <h4 id="sec-2.1.1">2.1.1 Source code blocks </h4>
  224. <div id="text-2.1.1">
  225. <p>Org has an extremely useful method of editing source code and
  226. examples in their native modes. In the case of R code, we want to
  227. be able to use the full functionality of ESS mode, including
  228. interactive evaluation of code.
  229. </p>
  230. <p>
  231. Source code blocks look like the following and allow for the
  232. special editing of code inside of the block through
  233. `org-edit-special'.
  234. </p>
  235. <pre class="src src-r">
  236. ,<span style="color: #add8e6;">## </span><span style="color: #add8e6;">hit C-c ' within this block to enter a temporary buffer in r-mode.
  237. </span>
  238. ,<span style="color: #add8e6;">## </span><span style="color: #add8e6;">while in the temporary buffer, hit C-c C-c on this comment to
  239. </span>,<span style="color: #add8e6;">## </span><span style="color: #add8e6;">evaluate this block
  240. </span>a <span style="color: #98fb98;">&lt;-</span> 3
  241. a
  242. ,<span style="color: #add8e6;">## </span><span style="color: #add8e6;">hit C-c ' to exit the temporary buffer
  243. </span></pre>
  244. </div>
  245. </div>
  246. <div id="outline-container-2.1.2" class="outline-4">
  247. <h4 id="sec-2.1.2">2.1.2 dblocks </h4>
  248. <div id="text-2.1.2">
  249. <p>dblocks are useful because org-mode will automatically call
  250. `org-dblock-write:dblock-type' where dblock-type is the string
  251. following the <code>#+BEGIN:</code> portion of the line.
  252. </p>
  253. <p>
  254. dblocks look like the following and allow for evaluation of the
  255. code inside of the block by calling <code>\C-c\C-c</code> on the header of
  256. the block.
  257. </p>
  258. </div>
  259. </div>
  260. <div id="outline-container-2.1.3" class="outline-4">
  261. <h4 id="sec-2.1.3">2.1.3 R blocks </h4>
  262. <div id="text-2.1.3">
  263. <p>In developing RweaveOrg, Austin created <a href="existing_tools/RweaveOrg/org-sweave.el">org-sweave.el</a>. This
  264. allows for the kind of blocks shown in <a href="existing_tools/RweaveOrg/testing.Rorg">testing.Rorg</a>. These blocks
  265. have the advantage of accepting options to the Sweave preprocessor
  266. following the #+BEGIN<sub>R</sub> declaration.
  267. </p>
  268. </div>
  269. </div>
  270. </div>
  271. </div>
  272. <div id="outline-container-3" class="outline-2">
  273. <h2 id="sec-3">3 tasks </h2>
  274. <div id="text-3">
  275. </div>
  276. </div>
  277. <div id="outline-container-4" class="outline-2">
  278. <h2 id="sec-4">4 buffer dictionary </h2>
  279. <div id="text-4">
  280. <p>LocalWords: DBlocks dblocks
  281. </p></div>
  282. </div>
  283. <div id="postamble"><p class="author"> Author: Dan
  284. <a href="mailto:dan@Tichodroma">&lt;dan@Tichodroma&gt;</a>
  285. </p>
  286. <p class="date"> Date: 2009-02-05 21:16:20 EST</p>
  287. <p>HTML generated by org-mode 6.20f in emacs 22</p>
  288. </div></body>
  289. </html>