
Explore best practices for R, manage RStudio projects, and master version control with git and GitHub, then apply functional programming and reproducible environments with Ram and rig.
Explore creating and managing RStudio projects, compare absolute and relative paths, disable the workspace and .RData for reproducibility, and customize the IDE while learning shortcuts and organization practices.
Download and install the latest R 4.4.0, install Rtools, and set up RStudio across Windows, macOS, or Linux to prepare your development environment.
Explore the RStudio interface by navigating its panes—the console, terminal, and background jobs; environment, history, connections; and the file system, plots, packages, help, viewer, and presentation panes.
Discover how RStudio projects organize related files in a portable folder with a dedicated project file. Create and open projects to start fresh sessions and set per-project options.
Explore using a project working directory and relative paths in R to avoid hard-coded paths, enable portable scripts, and navigate folders with tab completion and dot-dot shortcuts.
Avoid relying on the workspace and .RData files, as they hinder reproducibility; disable startup restores and define objects like seed directly in the script.
Learn to customize RStudio with global options for the R version, startup, history, and graphics backend. Tailor code editing, appearance, and pane layouts with themes, fonts, and indentation.
Set up a structured R project by organizing folders (assets, data, outputs, scripts, resources) and using the fs package to automate folder creation.
Apply system fonts in ggplot2 by setting the font family in theme and using the graphics device, then install fonts from Google Fonts and verify names with system fonts.
Discover essential RStudio shortcuts for labeling, executing code, piping, commenting, and quickly switching between script and console.
Learn to write readable R code by following the tidyverse style guide, focusing on labeling, headings, indentation, spacing, and sensible object naming for clearer analyses.
Learn best practices for naming folders and files in R projects, avoiding spaces and special characters, and using underscores or dashes with a leading underscore or dash to maintain order.
Learn how to document code by outlining with hashes and dashes, write first-level labels using ctrl-shift-r, and compare good versus bad syntax.
Learn R object naming conventions: use lowercase, do not start with numbers or underscores, and separate words with underscores. End names with object type like _list, _vec, _tbl, or _sf.
Enforce consistent spacing in R code by enabling style diagnostics, applying one space around operators and after commas, and avoiding spaces between function names and parentheses to boost readability.
mastering r's control flow functions teaches correct if and switch syntax, brace placement, whitespace around operators, and adding feedback for invalid inputs to ensure clear, reliable code.
Wrap R code to 80-character lines, manage long strings in plot titles, and use double-click to select content inside parentheses or brackets.
Adopt idiomatic R practices: assign with assign operator and avoid = for assignment; use double quotes for text and true/false for booleans; name functions with verbs and apply early returns.
Explore using pipes to streamline data transformations in R, with iris examples, summarize numeric variables, convert to long format, and format ggplot2 code with clean pipe conventions.
Mastering R with FD canopy height function from Forest Data package, lecture shows organizing code into error handling blocks, input paths, tile management, and readable layer names for terra crop.
Discover how version control records changes to files over time, creating snapshots you can revert to, using Git with GitHub and the command line.
Install git on your system, choosing the correct installer for Windows, macOS, or Linux, then verify success by running git and git version in the shell.
Explore how GitHub serves as a web-based platform for version control and collaboration that works with git and provides cloud hosting, developed and maintained by Microsoft.
Create and verify a GitHub account by completing the signup steps, including entering email, setting a password and username, and verifying via email to access your dashboard.
Master git and GitHub integration for RStudio by configuring user credentials, connecting both tools, and setting up SSH keys to securely access your GitHub account.
Enable the version control interface for RStudio projects in tools > global options > git/svn. Browse to git.exe in the Git bin directory and click OK.
Connect your local git to GitHub by configuring global user.name and user.email in Git via RStudio or the terminal, then verify settings and prepare for GitHub access.
Connect your GitHub account to local git using SSH keys, create and paste a public key, and manage RSA private keys for secure per computer access.
Enable two-factor authentication for your GitHub account to boost security. Scan the QR code with an authenticator app, use six-digit codes, and save recovery codes for secure sign-in.
Learn to set up git with R projects, clone or create local and remote repositories on GitHub, and master the staging, commit, push, and pull workflow.
Learn how to create a project in RStudio with a git repository, connect to a remote GitHub repository, and push changes from local to main after staging and committing.
Create a second repository for an existing project, initialize git, add and commit a readme, push to a remote, and use a dot git ignore to exclude data.
Create a remote repository on GitHub, clone it into RStudio via version control, then git add, git commit, and git push to synchronize the local project with the remote repository.
Clone an empty project from a repository using RStudio's version control, stage and commit changes with git, and push to the remote after connecting via the initial setup.
Learn how to clone a repository, download it as a zip, and explore code across accounts. Understand private repositories, access controls, and how to invite collaborators and manage permissions.
Explore git clone workflows in R Studio, change the remote origin with set URL, and push to a new repository or fork the original.
Learn to clone repositories using the command line and different IDEs, including creating directories, navigating with cd, and running git clone for projects with Python notebooks.
Learn how to delete remote repositories on GitHub safely from repository settings, confirm deletion, and understand how local repositories remain usable when the remote is removed.
Discover essential git commands, including git status, git log, and git pull, to manage local and remote repositories, track commits, and synchronize changes on the main branch.
Mastering R teaches how to undo changes with git reset, restore, and revert, including uncommitting last commits, using hashes, and safeguarding history before pushing.
Learn how git reset works, using a commit hash to drop later commits while preserving file changes, and a --hard reset to delete changes and commits, illustrated with buggy code.
Learn how the git revert command inverts changes up to a commit, creates a new commit while preserving history, and why it’s recommended for the last commit to avoid conflicts.
Learn how to undo uncommitted changes with git restore by restoring a single file to its previous commit status, using the file name without a commit hash.
Learn to manage git branches for robust feature development, including creating, switching, merging, pushing, and deleting local and remote branches.
Master essential git commands for version control, including git init, gitignore, status, log, add, commit, push, and branch management, and learn moving files through staging to local and remote repositories.
Work with spatial data on Tenerife's municipalities, processing a satellite image as spat raster to map vegetation via ndvi from near-infrared and red bands, and learn version control and commits.
Fork the initial repository and clone it to your local machine, then configure the remote to your account using secure shell keys and verify scripts and package setup.
Install R packages with the pack package, then use map view, Terra, tidy Terra, and tidyverse to work with satellite imagery, vegetation indices, and Tenerife municipalities, timing tasks with TikTok.
Update your R version to avoid viewer errors with the Mapview package, and follow steps to download R and RStudio and set a specific R version in Global Options.
Get Tenerife municipalities by a three-step workflow: download Spain’s municipalities (8204 features), isolate Tenerife province, and spatially filter polygons inside the island boundary.
Select the La Orotava municipality with a dplyr filter, while creating a dev branch from development branch to practice git workflows and push changes to origin.
Download a Sentinel-2 image for the selected municipality using the RSI package, saving a cloud-free 4 May 2024 tile and visualizing it with an RGB composite.
demonstrates handling large files in version control by showing a 160 MB image triggering github's 100 MB limit and guiding git reset --hard and ignoring the sentinel data with .gitignore.
Learn how to remove accidentally pushed files from a remote repository by using git rm -r to delete the target folder locally, then push the deletion to sync the remote.
Merge the main and dev branches after validating a fresh R session and checking packages, paths, and warnings; then commit and push using git commands for version control.
Restart the R session, load the packages, apply the World Geodetic System of 1984, transform geographic coordinates from degrees, and use git restore to revert to the previous commit.
In real project part two, restart R for a fresh session, split analysis into two scripts, and save/export objects after expensive steps to enable modular, reliable workflows.
Load packages, remove the unused TikTok dependency, and load geospatial data with read_sf for municipality data, then load a sentinel satellite image with Terra and Rast, preparing for ndvi analysis.
Calculate the ndvi from sentinel sr imagery using near-infrared and red bands, with proper scaling, and track changes with git diff, commits, and deleting the dev branch.
Create an ndvi visualization in ggplot using a spat raster from tidyterra, apply a red yellow green gradient, add dynamic labels for the selected municipality, and save the figure.
Compare functional and object oriented programming in R, noting immutable data and recursion versus loops. Learn to write basic and advanced functions, with tidy evaluation and purrr.
Learn to define and use R functions, create a sum example, and perform unit conversions (inches to cm, feet to meters) plus cylinder volume with mutate on the trees dataset.
Discover how to organize functions in an R project by creating a utilities script with inches to centimeters, feet to meters, and volume calculations, loaded via source in functional workflow.
Employ advanced tidyverse techniques to compute the mean of numeric iris variables, pivot to long format, and wrap the workflow into a reusable r function.
Build a reusable R function that computes the mean across numeric variables for any dataset using tidy evaluation with braces, and enable grouping by a user-specified variable.
Explore functional programming in R with map(), compare it to a for loop, and build message strings using an anonymous function and str_glue to output a messages list.
Master iteration with map() in R by building linear models for each iris species, using for loops, split lists, and anonymous functions for concise summaries.
Use map2 to iterate over two lists in parallel, pairing fluids with colors via an anonymous function that takes two arguments and uses str_glue to format fluid color.
Apply map2 to tune a ranger random forest regression in R, exploring n trees and m3 via a params table and grid search, and assess r-squared on iris data.
Learn to use pmap() to iterate over three or more vectors by wrapping inputs in a list and using an anonymous function with str_glue to combine fluid, color, and rounded.
Apply functional programming to process Tenerife municipalities by downloading satellite images, computing vegetation indices, and mapping results; create modular functions for each step and integrate them into an R workflow.
Fork and clone the BPT start functional programming project from GitHub, create a new RStudio project with git, and begin the simple and final analyses.
Load packages, create a reusable R function to download and filter Tenerife municipalities, and commit the workflow for version control using simple feature data.
Learn to download Sentinel-2 satellite images for each municipality by splitting the list by id, mapping a download function, and selecting the red (V04) and near-infrared (V08) bands.
Prepare data for visualization by defining a calculate ndVi function, apply it to a list of sentinel images with map, and save results as ndVi rasters.
Learn advanced data wrangling to prepare data for visualization by fixing municipality names, handling multiword names, and applying vectorized, reproducible transforms.
Create ndvi maps by defining the create_ndvi_gg function, iterating over ndvi rasters and Tenerife municipalities, then load terra and save the resulting maps.
Export the maps by using anonymous functions and map iterations to generate 31 ndvi plots across municipalities, then save and commit the results to a remote repository.
Explore reproducible environments by using Git and GitHub for version control, the RM package to manage R versions and package versions, and Docker for containerized environments.
Explore defining packages, libraries, and repositories in R, learn how to build and send packages to a repository, and manage system, user, and project libraries; major, minor, and patch versions.
Explore the ramp package for consistent project library management, recording package versions in a rem dot log, and using snapshot, restore, and status to reproduce environments across collaborators.
Learn how to create a ramp-based RStudio project, install packages like dplyr into the project library, and review startup messages, logs, and package status for reliable workflows.
Record installed packages in the lockfile and log file with rm snapshot to resolve inconsistent states, updating versions for packages like dplyr and ggplot2 when used in scripts.
Initialize renv inside a project to manage dependencies across IDEs and keep a synchronized log. Leverage the package cache to speed installs, and snapshot only the packages you actually use.
Learn to install other package versions with the Posit Package Manager, explore Bioconductor repositories, and install specific versions such as dplyr, managing dependencies and logs across projects.
Learn to update packages in a renv project using the update function, upgrading dplyr to the latest version and recording the changes in the log file with a rem snapshot.
Learn how to remove unused packages from an R project, using dplyr and ggplot2 as examples, through status checks, REM snapshot, and updates to keep the project library clean.
Learn how to collaborate on R projects using renv and git, initialize projects, manage packages like dplyr and ggplot2, and share reproducible environments with snapshot and restore workflows.
Learn how to deactivate and reactivate renv in an R project, remove the autoloader and project library, optionally clean files, and reinitialize with rem init.
Resolve version mismatches between the current R version and the log file by restoring packages to the project library, and understand how compatibility issues arise when R versions differ.
Install the R live rig, the R installation manager, by downloading the Windows installer from the releases page and running it, then verify with rig -h in a terminal.
Learn to install and switch between R versions using the rig tool, align versions with project logs, and run an RStudio session with the required 4.2.3 environment.
Upgrade the R version in a project with renv by launching RStudio in the latest version, restoring the project library, and updating the log with renv snapshot.
Manage renv caveats by locking the R version, leveraging rig to switch versions, and track the operating system to support reproducible analyses.
Implement ramp in the real project using init to copy 156 packages into the project library, leveraging the user library cache, and verify status.
Welcome to Mastering R: Best Practices and Essential Tools!
In this course, we aim to address a significant gap in the market by equipping R users with the knowledge and skills needed to implement best practices. You will learn how to organize your projects effectively, adhere to the highest coding standards, and utilize a suite of powerful tools that will enhance your productivity and collaboration.
Our focus will be on providing you with practical, everyday techniques that streamline your workflow and make your code robust and shareable. By the end of this course, you'll be able to avoid the common pitfall of "this script works only on my machine" and ensure your projects are reproducible and portable.
Course Content:
Section 01: Introduction to the course
Section 02: Rstudio IDE
Setting up and navigating RStudio for an optimized coding environment.
Essential shortcuts and tips
Section 03: Best coding practices
Learn to write clean, efficient and maintainable R code
Section 04: Version control with Git and GitHub - Configuration
Installation and setup of Git and GitHub
Generate 2 Factor Authentication
Section 05: Version control with Git and GitHub - Working with repositories
Managing your code changes and collaborating with others using Git and GitHub
Learn different ways of creating and cloning repositories
Understand how privacy works
Git workflow
Section 06: A real project
Implement the previous learning in a real-world project
Section 07: Introduction to functional programming
Learn what functional programming is
Create basic and advanded functions
Iteration
Section 08: Functional programming in our real project
Change our real-world project to a project based in functional programming
Section 09: Reproducible environments
Creating reproducible R environments to ensure consistent project dependencies
Course Details:
Duration: Approximately 9 hours
Lessons: Over 100 lessons
Join us on this journey to mastering R, and take your coding skills to the next level!