我正在尝试更好地为我的项目使用 org-mode。我认为识字编程特别适用于数据分析领域,而 org-mode 让我们可以做一些非常棒的识字编程。
我想你们中的大多数人都会同意我的观点,即编写分析的工作流程与大多数其他类型的编程不同。我不只是编写程序,我探索数据。而且,虽然其中许多探索都是死胡同,但我不想完全删除/忽略它们。我只是不想每次执行 org 文件时都重新运行它们。我也倾向于查找或开发我想放入分析模板的有用代码块,但其中一些块不会与每个项目相关,我想知道如何让 org-mode 忽略这些执行整个缓冲区时的块。这是一个简化的例子。
* Import
- I want org-mode to ignore import-sql.
#+srcname: import-data
#+begin_src R :exports none :noweb yes
<<import-csv>>
#+end_src
#+srcname: import-csv
#+begin_src R :exports none
data <- read.csv("foo-clean.csv")
#+end_src
#+srcname: import-sql
#+begin_src R :exports none
library(RSQLite)
blah blah blah
#+end_src
* Clean
- This is run on foo.csv, producing foo-clean.csv
- Fixes the mess of -9 and -13 to NA for my sanity.
- This only needs to be run once, and after that, reference.
- How can I tell org-mode to skip this?
#+srcname: clean-csv
#+begin_src sh :exports none
sed .....
#+end_src
* Explore
** Explore by a factor (1)
- Dead end. Did not pan out. Ignore.
- Produces a couple of charts showing there is not interaction.
#+srcname: explore-by-a-factor-1
#+begin_src R :exports none :noweb yes
#+end_src
** Explore by a factor (2)
- A useful exploration that I will reference later in a report.
- Produces a couple of charts showing the interaction of my variables.
#+srcname: explore-by-a-factor-2
#+begin_src R :exports none :noweb yes
#+end_src
我希望能够使用 org-babel-execute-buffer 并让 org-mode 以某种方式知道跳过代码块 import-sql、clean-csv 和 explore-by-a-factor-1。我希望它们在 org 文件中,因为它们与项目相关。毕竟,明天有人可能想知道为什么我如此确定 explore-by-a-factor-1 没有用。我想保留该代码,这样我就可以完成绘图或分析或其他任何事情并继续进行,但不是每次我重新运行所有内容时都运行它,因为没有理由运行它。与 clean-csv 一样。我想要它,记录我对数据做了什么(以及为什么),但我不想每次都重新运行它。我将只导入 foo-clean.csv。
我在谷歌上搜索并阅读了一堆 org-mode 邮件列表档案,我能够找到一些想法,但不是我想要的。导出文件时,EXPORT_SELECT_TAGS、EXPORT_EXCLUDE_TAGS 很棒。在创建实际的源文件时, :tangle 标头效果很好。我不想做这两件事。我只想执行缓冲区。我希望能够以类似的方式定义要执行或忽略的代码块。我想我想找到一种方法来拥有一个 org 变量,例如:
EXECUTE_SELECT_TAGS
这样我就可以简单地标记我的各种代码块并完成它。如果我可以然后只使用带有特定标签的源块来运行该文件,那就更好了。我找不到这样做的方法,我想我会在询问/乞求 org-mode 中的新功能之前先询问一下。