lecture_11

lecture_11 - BIOS 735 Statistical Computing Michael Wu...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: BIOS 735: Statistical Computing Michael Wu Lecture 11: Good Coding Practice and Development in R September 29, 2011 Michael Wu (Lecture 11) BIOS 735 September 29, 2011 1 / 14 Writing Code in R Important aspects of the code that you write: Code should work and produce accurate results Code should be fast Code should be general and useful to others Code should disseminated There is no such thing as “best” coding practices, but there are some things which can be considered “good” coding practice. In a typical intro CS class, there is enormous emphasis on organizing code Software and computing machinery have changed so some things are not necessarily most relevant anymore There are a lot of aspects that are personal preference and style, but the key is consistenct Michael Wu (Lecture 11) BIOS 735 September 29, 2011 2 / 14 Basic Principles of Good Coding (by Broman) Working code – most important! I No bugs I Produces accurate results Speed I Has to run within reasonable time frame I Improved memory and CPU speeds are constantly racing with new data analysis requirements Readable I Fixable I Extendable Key: think before you code → fewer bugs/re-writes → can reuse code → less time in the long run. Michael Wu (Lecture 11) BIOS 735 September 29, 2011 3 / 14 Organizing your Code Put code into files which can be source ed I Put related functions into the same file I Name your files in a reasonable manner: foo.R vs. calc.pairwise.cor.R I Put a header at the top of the file describing who write it, the version/date, what it contains, and how it fits in with the larger program. F See Broman Example I Generally, you want all of your code to be in files that are less than 2-3000 lines Create an R package....
View Full Document

Page1 / 14

lecture_11 - BIOS 735 Statistical Computing Michael Wu...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online