R 项目/包开发的 ESS 工作流程

发布于 2024-09-05 04:43:54 字数 202 浏览 4 评论 0原文

谁能分享他在 ESS 下 R 项目开发工作流程的经验吗?我尝试了好几次学习emacs,但还是没有掌握。作为编辑我可以理解ESS,但是ESS中有项目视图吗?设置/查看 R 项目目录、编码和测试的有效方法是什么?ESS 如何具有促进整个过程的优势?

您是否仅将 ESS 用作良好的 R 编辑器,还是倾向于在 ESS 中模拟 R IDE 环境?

感谢您的任何建议。

Can anyone share his experience on workflow for R peject development under ESS? I tried several times to learn emacs but I have not get it yet. I can understand ESS as an editor, but is there a project view in ESS? what's the efficient ways to set up/view R project directory, coding, and testing, and how's ESS has an edge to facilitate the whole process?

Do you use ESS as a good R editor only or tend to emulate a R IDE environment within ESS?

Thanks for any advices.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦里的微风 2024-09-12 04:43:54

听起来你在问两个不同的问题。
其中一个问题涉及工作流程,另一个问题涉及 ESS 的使用。
由于我使用 StatET 和 Eclipse,因此我将分享我关于您问题的工作流程方面的经验。

与 Vincent 一样,我也遵循 Josh Reich 在这里制定的工作流程(另请参阅 Hadley 的有用评论):
统计分析和报告撰写的工作流程

尽管项目之间可能有所不同,我倾向于有几个主要的 R 文件

  • import.R:这会导入数据文件并进行任何必要的清理和操作
  • 分析。R:这会生成我需要的任何最终报告的输出
  • main.R:这会调用 import.R 和analysis.R

的目的是让 import.R 和 analysis.R 代表生成任何分析的最终结果的完整且最终的工作流程。

就分析项目的目录结构而言,我通常还会有以下文件夹

  • data:用于存储任何原始数据文件
  • meta:用于存储元数据,例如作为变量标签、测试评分系统、重新编码信息等。
  • 输出:用于存储我的分析生成的任何图形、表格或文本,我可能希望将其合并到外部程序
  • temp :在探索数据和头脑风暴分析时,我喜欢将代码键入文件而不是使用控制台。我倾向于将这些标记为 temp1.R、temp2.​​R、temp3.R。我将它们存储在临时文件夹中。这样我就有了一个易于访问的永久记录。如果分析成为最终结果,它们将被合并到主要 R 文件之一(即 import.R 或 Analysis.R)
  • 函数:如果我认为几个项目都需要一个函数,我经常将每个文件放置一个函数,或者将一组相关函数放置在名为“functions”的文件夹中的文件中。当包开发的正式需求超出需要时,这使得跨项目重用功能变得相对容易。
  • library:如果我想创建一些我认为特定于项目的通用函数,我会将它们放在此文件夹中
  • save:用于存储任何已保存的 R 对象的文件夹

StatET 和 Eclipse 可以轻松地与此类文件系统进行交互。
当然,考虑到所有使用 ESS 和 Emacs 的 R 专家,我确​​信它也能很好地处理与文件系统的交互。

It sounds like you're asking two separate questions.
One question concerns workflow and the other concerns using ESS.
As I use StatET and Eclipse, I'll just share my experience regarding the workflow aspect of your question.

As with Vincent I also follow something like the workflow set out by Josh Reich here (also see Hadley's useful comments):
Workflow for statistical analysis and report writing

Although it can vary between projects, I tend to have a couple of main R files

  • import.R: this imports data files and does any necessary cleaning and manipulation
  • analyse.R: This generates the output that I need for any final report
  • main.R: This calls import.R and analyse.R

The aim is for import.R and analyse.R to represent the complete and final workflow for producing the final results of any analyses.

In terms of a directory structure for an analysis project, I'll often also have the following folders

  • data: for storing any raw data files
  • meta: for storing meta data, such as variable labels, scoring systems for tests, recoding information, etc.
  • output: for storing any graphics, tables, or text generated by my analyses that I might want to incorporate into an external program
  • temp: When exploring the data and brainstorming analyses, I like to type code into files instead of using the console. I tend to label these temp1.R, temp2.R, temp3.R. I store these in a temp folder. That way I have a permanent record that's easily accessible. If the analyses become final they get incorporated into one of the main R files (i.e., import.R or analysis.R)
  • functions: If I think that a function will be needed across a couple of projects, I often place it one function per file or a set of related functions in a file in a folder called functions. This makes it relatively easy to reuse functions across projects, when the formal requirements of package development are more than needed.
  • library: If I want to create some general functions that I think will be project specific, I'll place them in this folder
  • save: A folder to store any saved R objects

StatET and Eclipse make it easy to interact with such a file system.
Of course, given all the R gurus that use ESS and Emacs, I'm sure it also handles interactions with the file system well.

冷情 2024-09-12 04:43:54

我不太确定您对此问题的答案有何期望。举个例子,我偷了(并改编)了不久前(Josh Reich)在这里建议的系统

为每个项目创建一个文件夹,并将您的工作分成一堆不同的 .R 文件:

  • Load.R 用于将原始数据导入 R;
  • Prep.R 用于清理数据、重新编码变量等;
  • Func.R 用于编写评估所需的任何自定义函数;和
  • Eval.R 用于运行你的最后的东西。

如果这不适合您的风格,只需更改它即可。

然后,您可以使用一个主文件来依次调用每个部分(有利于再现性),或者在不同阶段保存并让各个脚本加载适当的数据(如果某些准备工作需要大量计算,则很好) /时间密集)。

**

另一方面,链接中发布的技巧确实帮助我进入了 ESS。它将 Shift-Enter 变成一站式 ESS 商店:http://www.kieranhealy.org/blog/archives/2009/10/12/make-shift-enter-do-a-lot-in-ess/

I'm not exactly sure what you expect as an answer on this one. I, for one, have stolen (and adapted) a system that was suggested here a little while ago (by Josh Reich):

Create a folder for every project, and split up your work in a bunch of different .R files:

  • Load.R for getting your raw data into R;
  • Prep.R for cleaning the data, recoding variables, etc.;
  • Func.R for coding any custom functions you will need for evaluation; and
  • Eval.R for running your final stuff.

If that doesn't fit your style, just change it.

Then, you can either have a master file to call each of the parts one after each other (good for reproducibility), or save at different stages and have the individual scripts load the appropriate data (good if some of the prep work is very computationally/time intensive).

**

On a different note, the trick that is posted at the link really helped me get into ESS. It turns Shift-Enter into a one-stop-ESS-shop: http://www.kieranhealy.org/blog/archives/2009/10/12/make-shift-enter-do-a-lot-in-ess/

花开雨落又逢春i 2024-09-12 04:43:54

其他人为您提供了一些关于如何为项目设置目录/文件结构的好主意。

您还询问了“项目视图”,在这种情况下您可能需要查看 Emacs 代码浏览器 (欧洲央行)。

您可以在其网站上找到一些实际运行的屏幕截图:
http://ecb.sourceforge.net/screenshots/index.html

Others have given you some good ideas about how to setup your directory/file structure for a project.

You also asked about "project views," in which case you might want to look into the Emacs Code Browser (ECB).

You can find some screen shots of it in action on its site, here:
http://ecb.sourceforge.net/screenshots/index.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文