Whilst not specific to R, the following principles can be a guide as to how to write good programs in R.