views:

428

answers:

3

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.

+3  A: 

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/

Vincent
thanks for the great shift-enter trick.
ahala
Glad that it helped!
Vincent
+4  A: 

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): http://stackoverflow.com/questions/1429907/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.

Jeromy Anglim
Edited the original answer to get the right name. Thanks for finding the page Jeromy!
Vincent
+1  A: 

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

Steve Lianoglou
Thanks. This is what I am looking for.
ahala