My Programming Environment

by on under R
4 minute read


In the course of my work with “R” on Deep Creek Lake associated projects and calculations, I find that certain programming idioms are repeated. In this section I describe briefly how I do things.

1. Introduction

I’m from the old school of programming when Fortran was the language to work with. I did a lot of things with it and acquired a set of habits that are hard to break. I do try hard to keep up with what’s going on in the programming world, but not having to deal with a corporate set of rules, I do what suites me best. For example, as one develops software one’s product should really be under strict version control. A system such as GIT, is probably the way to go, but I haven’t gotten there yet. Perhaps sometime during the current process of documenting what I’ve done over the last 7 years I may actually learn it sufficiently for it to be useful.

Another example, this documentation process is done via Markdown, because it is easier to generate the appropriate HTML and publish it on the web. I’ve resisted this for s while, but now found it to be easy to work with, even though there are things that I feel are not complete. So here I present how I do stuff.

2. Software Used

“R” is my programming language of choice. Since Fortran I’ve worked with C, C++, Python, Ruby, and now R, in that order. Python has come a long way and now features many of the same capabilities that R has.

3. File Organization

A project, such as my Deep Creek Lake project, has clearly may sub-projects or components. Figure 1 shows how I structure the work on a sub-project, component or task, whatever you want to call it.

Task Work Flow Figure 1. Typical Structure of Programming Organization.

The main folder has the name that can identify it as a sub-project folder. All files are referenced to this location.

I put all code in the ‘code’ directory.

All input data goes into “data” folder.

All results into the ‘results’ folder. These are typically outputs from the program units in the “code” folder. Sometimes results are used as input data to another program unit in the code folder.

The ‘functions’ folder contains R scripts that are functions and that are easily used. Functions are included in R program units located in the ‘code’ folder. In those units they are invoked simply with this line of code:


Here “credit.R” is a function that, when called properly, will insert on a graph something like the following, for example,:

Figure 2. Sample of the Use of the ‘credit.R’ Function.

There are a number of functions that I make use of on a regular basis. All are described below in the section called “Description of my Functions”

The ‘literature’ folder collects materials from the literature that assist in solving the problem at hand. The literature can be in the form of reports, papers, books, web articles, or links.

The ‘documentation’ folder contains write-ups pertaining how I did solve the problem. These are typically done with Apple’s Pages software, but could also be done as a Markdown document or a word document or just a text file with a brief description.

The ‘references’ folder contains the documents that are referenced by the documentation in the ‘documentation’ folder.

4. A Description of My Functions

“credit.R” is a function that I find useful in identifying what programming unit and the data a particular graph was generated with. Here it is:

# This function can be called with a plot to place information at the bottom of the plot
# to provide a level of accountability as to what software created the plot and when.
# " is the name of the script from which this function is called."
# Sample Call: credit("credit.R")
credit <- function({
# To put text on the lower right hand side of the plot (like to script name and date) <- Sys.Date()
	script.txt <- paste("PLV: \"",, "\"  ",, "  ", sep="")
	mtext(script.txt, side=3,  cex=0.75, line=-1, adj=1)

There are other functions that I use commonly. As time permits these will be written up and collected here.

NOTE: There is no specific script associated with this.

PLV: 9/4/2017

R, bash
© 2017 PLV Some Rights Reserved - To comment on any of my work please email me at: moc.hcetsnes@etep