Adapted from Software Carpentry
Questions:
Objectives:
Keep your project folder structured, organized, and tidy. Create subfolders for:
RStudio projects help, and you can automate setup with packages such as ProjectTemplate.
Readable code matters more than clever code. Someone else should be able to understand your work quickly, and that someone is often you in six months.
Comments should explain what problem you are solving and why you made a decision. The how is usually clear from the code itself.
Separate your functions from analysis scripts and store them in a file you source() when you start a project. Small, single-purpose functions are easier to test and reuse.
Make sure your functions do the right thing. Tests build confidence and prevent regressions.
Repeated blocks of code are good candidates for functions. This makes your project easier to maintain and update.
Use consistent naming, indentation, and formatting. Style consistency makes collaboration easier.