Accessing aWhere’s R Scripts
aWhere Training Tutorial
aWhere provides R scripts in both English and Spanish. These scripts can be easily accessed through two methods:
- Download the scripts directly from the adaptER Platform app “R Scripts to Analyze Weather”. Please skip to Step 3 below if using this method.
2. Download the scripts from aWhere’s GitHub repository
The steps to access the GitHub repository are below. In order to access the most up-to-date training scripts we encourage you to download the scripts from aWhere’s GitHub repository of R-Training-Tutorials. GitHub allows aWhere’s programmers to make changes to code and release updates to ensure consistency. Version control systems keep revisions organized and allow developers to collaborate and download the latest version.
This tutorial will review how to access aWhere’s GitHub R-Training-Tutorials and explain best practices of version control. If you have never used R before, not to worry – we will guide you through the steps to start generating powerful weather visuals!
Tip: Have you already completed the tutorials on organizing your folder structure and getting your aWhere key and secret? If not, we encourage you to complete those steps first before jumping into R scripts!
Visit aWhere’s GitHub repository R-Training-Tutorials to view all current versions of the training scripts that will be used throughout this tutorial series.
There are 6 scripts (in both English and Spanish) in this repository and each produces unique outputs that can be used in reporting and decision-making.
Click the green button that reads “Clone.” This dropdown gives you the option to clone the contents of the repository to your local device or download a zip file of the scripts.
For beginner GitHub users, we suggest you click “Download ZIP.”
For more advanced users who would like to clone the repository to their device, please use that option. This tutorial will focus on using the files in a static way (i.e. as a downloaded file) but there are benefits to having the repository cloned locally. Cloning allows you to sync with the original remote scripts to keep them up-to-date with your local copy. Read more about cloning Git repositories here and version control at the end of this tutorial.
After the ZIP File is downloaded, please unzip it and find the folder current training scripts – this is the primary folder you will need. If you are downloading the scripts directly from the adaptER Platform using the first method, please save them in the Scripts folder (see below).
If you are following the suggested folder structure from the Tutorial: Organizing your File Structure, please save the scripts from the current training scripts folder in the Scripts folder in your main aWhere training folder.
Version Control in GitHub
To track how your code changes over time and develop scripts collaboratively, using version control software is essential. The most common tools for version control are GitHub and BitBucket, where you can create a repository for your project and share it with your colleagues.
An introductory tutorial for GitHub is available here: https://guides.github.com/activities/hello-world/
The general steps for version control (with key terms highlighted) include:
- Create a project repository (often abbreviated “repo”) where code files are stored.
- If the repo is created on the https://github.com website, this is known as “remote” as opposed to being “local” on your computer.
- The “master branch” is the default or original version of the code.
- The master branch should never be modified directly!
- As a developer who wants to modify the code, you should start a new branch off of the master for development.
- A “branch” is really just a copy of the another branch that you can modify without fear of making a big change that breaks the original code.
- “Clone” this branch onto your local computer.
- To “clone” a branch of a repo just makes a copy of it from the “remote” space to your “local” workspace.
- Always pull any changes made to the branch before you start making modifications.
- Modify the code in your development branch.
- After making changes, “add” the changed files.
- Describe the changes you made in a “commit” message.
- Commit messages should be short yet descriptive. For instance “fixed atmospheric correction equation” is a much better, more informative message than “updated code”.
- Each commit gets a unique number assigned to it, so you can always go back in time and see what changes were made.
- Push your changes to your development branch.
- If you would like the master branch to include your edits, initiate a “pull request” to alert the other developers about the changes you made.
- At this point, developers can assess the changes you made, write comments and discuss, all for the sake of making sure that there are no conflicts with the original code.
- If the other developers approve of your changes, you can merge your edits into the master branch.
By following the steps listed above, you can carefully monitor how your code changes over time and effectively develop code with a team.
Review the next tutorial in the series to start leveraging QGIS to make world weather maps with the Tutorial: Using aWhere Data with QGIS. If you want to skip the mapping and go straight to using R, please follow the Tutorial: Getting Started with aWhere’s R Scripts.
If you have any questions, please contact email@example.com