Coding after the workshop
For those who want to continue coding after the workshop, here are the steps you need to take. There are three things to take care.
- Save your scripts to your repo.
- Run your scripts.
- Create new projects.
1. Save your scripts to your repository
You need to save the files you created during the workshop to your Github repository. Codespaces are temporary. Github will delete unused Codespace after some time. Github repositories are long lasting. The files in your repo will remain on Github until you delete your repo or delete your account.
Start Codespace. In Visual Studio Code, click “bash”. Click “TERMINAL”.
To save the changed files to you repository, type “bash scripts/save_files.sh” after the $, and hit return/enter.
2. Run your scripts
There are several ways to run your scripts.
- Run R code using Github Codespace. You can run your code for free for 60 hours a month.
- Run R code on your computer. You need to install R, RStudio, and R packages on your computer. You can run your code for free for unlimted number of hours.
Run R code using Github Codespace
Currently, every free Github account has access to 120 core hours per month to run Codespaces. When you start a Codespace, by default it uses 2 cores. This means you can run a Codespace for 60 hours per month (120 core hours / 2 cores = 60 hours). For more information, visit Codespaces Billing.
Copy repository to your Github account
First step is to copy your repository from the workshop into your Github account. Go to your repository page on Github. There is a “Fork” button near the top. Creating a fork will copy the repo, and create a new repo in your Github account. Click the “Fork” button.
Click “Create a new fork” in the popup.
On the “Create a new fork” page, fill in the repository name, optionally add a description, and click “Create fork” button.
A copy of the repo will be added to your Github account.
Start a Codespace
Next step is to run Codespace on your repo in your Github account.
- Click the green “Code” button near the top of the page.
Click “Codespaces” tab.
a. If there are no Codespaces for the repo, click the green “Create codespace on main” button. The browser window loads the Codespace.
b. If a Codespace exists for the repo, click the three dots in the “On current branch” section.
Click “Open in Browser” in the popup window. This will restart an existing Codespace in a browser tab.
Stop RStudio and Codespace
After you finish your work for the day, you need to stop RStudio, push your code changes to your repository and, stop Codespace. If you don’t stop Codespace, it will continue to run and use up your free 60 hours a month.
To stop R, click the orange circle in the upper right of RStudio.
You’ll see a message “R Session Ended”. Close the browser tab for RStudio.
Go to the Visual Studio Code browser tab. Click “bash”. Click “TERMINAL”.
To save the changed files to your repository, type “bash scripts/save_files.sh” after the $, and hit return/enter.
To stop Codespace, click the blue area in the lower left corner of Visual Studio Code.
A popup window will appear. Click “Stop Current Codespace”.
After a little while, you will see a “Codespace is stopped” message. You can now close the browser tab.
Run R code on your computer
If you want to run R code on your computer, you need to install RStudio, R, and R packages on your computer.
- Complete the steps for Setup - local page > “Install R and RStudio”
- Complete steps for Setup - local page > “Install R packages”
- Download your repository to your computer.
Go to data-explorers-feb-2025 account page, and you should see your repository. Click on your repository. The repository page will have a green “Code” button.
When you click on “Code”, click the “Local” tab. Click on “Download ZIP”. A zip file for your repository will be saved to your computer.
Unzip the file. Click on workshop.Rproj
file to start RStudio on your machine. Now you can continue editing and running your project code.
3. Create new project
If you want to start a new project, you can create a new R project on Github or on your computer.
Create new projects on Github
I created a template you can use to create new projects that runs R and Rstudio on Github Codespace. R, RStudio, Codespace template.
Create new projects on your computer
Once you have R and RStudio installed on your computer, you can also create new projects. Follow the instructions on Setup - local page > Organizing your project folder to set up new projects. Follow the instructions on Setup - local page > “Install R packages” to install R packages.