function Start-Countdown {
param(
[int]$seconds
)
Write-Host "Download and installation of R, Git, and RTOOLS44; and download of RStudio will begin shortly." -ForegroundColor Magenta
Write-Host "If you need to cancel, please close the window"
Write-Host "This will take a few minutes!"
Write-Host "$seconds" -ForegroundColor Magenta
while ($seconds -gt 0) {
Start-Sleep -Seconds 1
$seconds--
Write-Host "$seconds" -ForegroundColor Magenta
}
Write-Host "Initiating..."
Start-Sleep -Seconds 1
}
Start-Countdown -seconds 10
New-Item -Path "$home/Software/GitLocal" -Type Directory
New-Item -Path "$home/Software/R" -Type Directory
$softwareDEST = "$home\Software"
$rEnvironPath = "$home\Software\R\.Renviron"
$rProfileSitePath = "$home\Software\R\Rprofile.site"
Add-Content -Path $rProfileSitePath -Value ('local({
r <- getOption("repos")
r["CRAN"] <- "http://cran.rstudio.com/"
options(
list(
download.file.method = "libcurl",
repos = r,
scipen = 999
)
)
})')
Write-Host "Rprofile.site created and added to file: $rProfileSitePath" -ForegroundColor Green
Add-Content -Path $rEnvironPath -Value ('R_USER="' + $softwareDEST + '\R"')
Add-Content -Path $rEnvironPath -Value ('R_PROFILE="' + $softwareDEST + '\R\Rprofile.site"')
Add-Content -Path $rEnvironPath -Value ('RTOOLS45_HOME="' + $softwareDEST + '\R\RTOOLS45"')
Add-Content -Path $rEnvironPath -Value ('PATH="${RTOOLS45_HOME}\usr\bin;${PATH}"')
Write-Host "`n.Renviron created and added to file: $rEnvironPath" -ForegroundColor Green
$rURL = "https://cran.r-project.org/bin/windows/base/R-4.5.1-win.exe"
$rDEST = "$home\Downloads\R-4.5.1-win.exe"
$rInstallDirectory = "$softwareDEST\R\R-4.5.1"
$rCommandLine = "$rDEST /SILENT /DIR=$rInstallDirectory"
Write-Host "`nDownloading R from: $rURL"
Write-Host "`nPlease Wait..."
Invoke-WebRequest -Uri $rURL -OutFile $rDEST
Write-Host "`nR Download Success" -ForegroundColor Green
Start-Process -FilePath "cmd.exe" -ArgumentList "/c $rCommandLine" -Wait
Write-Host "`nR Installed to: $rInstallDirectory" -ForegroundColor Green
$RTOOLS45URL = "https://cran.r-project.org/bin/windows/Rtools/rtools45/files/rtools45-6608-6492.exe"
$RTOOLS45DEST = "$home\Downloads\rtools45-6608-6492.exe"
$rtoolsInstallDirectory = "$softwareDEST\R\rtools45"
$rtoolsCommandLine = "$RTOOLS45DEST /SILENT /DIR=$rtoolsInstallDirectory"
Write-Host "`nDownloading RTOOLS45 from: $RTOOLS45URL"
Write-Host "`nPlease Wait..."
Invoke-WebRequest -Uri $RTOOLS44URL -OutFile $RTOOLS44DEST
Write-Host "`nRTOOLS45 Download Success" -ForegroundColor Green
Start-Process -FilePath "cmd.exe" -ArgumentList "/c $rtoolsCommandLine" -Wait
Write-Host "`nRTOOLS45 Installed to: $rtoolsInstallDirectory" -ForegroundColor Green
$gitURL = "https://github.com/git-for-windows/git/releases/download/v2.51.0.windows.2/Git-2.51.0.2-64-bit.exe"
$gitDEST = "$home\Downloads\Git-2.51.0.2-64-bit.exe"
$gitInstallDirectory = "$softwareDEST\Git"
$gitCommandLine = "$gitDEST /SILENT /DIR=$gitInstallDirectory"
Write-Host "`nDownloading Git from: $gitURL"
Write-Host "`nPlease Wait..."
Invoke-WebRequest -Uri $gitURL -OutFile $gitDEST
Write-Host "`nGit Download Success" -ForegroundColor Green
Start-Process -FilePath "cmd.exe" -ArgumentList "/c $gitCommandLine" -Wait
Write-Host "`nGit Installed to: $gitInstallDirectory" -ForegroundColor Green
$rstudioURL = "https://download1.rstudio.org/electron/windows/RStudio-2025.09.1-401.exe"
$rstudioDEST = "$home\Downloads\RStudio-2025.09.1-401.exe"
Write-Host "`nDownloading RStudio from: $rstudioURL. Please note you need admin access to install" -ForegroundColor Magenta
Write-Host "`nPlease Wait..."
Invoke-WebRequest -Uri $rstudioURL -OutFile $rstudioDEST
Write-Host "RStudio Downloaded $rstudioDEST" -ForegroundColor Green
Start-Process "https://youtu.be/QB7ACr7pUuE?si=KDnBoztaP3lUbGnv"
Write-Host "All Done! Please close this window" -ForegroundColor MagentaNew R User Configuration
Introduction
This chapters serves as a step-by-step guide for downloading & installing software, setting software configurations, and creating necessary directories. See each section for details
Lets Get Started!
Please read through each section before downloading, installing, and saving to file locations!!
Throughout this document, you will be given code to run. To copy & paste, hover over the code, and click the clipboard icon in the upper right-hand corner. If you have any questions or problems, please contact a CAAT Team member.
Folders & Software
The large chunk of code below will do the following:
Create Required Folders:
Software –>
GitLocal
Git
R
Create Required Files:
.Renviron– creates global environment variables that load during each R session; this file and its contents is important for package management and reproducibility purposes.
Rprofile.site– sets global R options, default package repositories, and download methods; it is also important for package management and reproducibility purposes.
Download & Install Software:
R Version 4.5.1– Currently most compatible version of R
RTOOLS45– necessary to compile packages.
Git– important for version control and collaboration
Download RStudio and redirect you to the DAYS EITS Software Request Page (see Requesting RStudio Installation below for details)
To run the code below:
Type: Win + R to open the Run prompt
Type “powershell” + Enter to open PowerShell
In PowerShell, paste and run the following:
You should now have:
Software/GitLocal folders
Software/R folders containing .Renviron and Rprofile.site files
R 4.5.1, Git, and {RTOOLS45} installed
Rstudio downloaded, but not yet installed
Requesting RStudio Installation
Configure RStudio
Open RStudio after EITS has installed RStudio
Install Packages Run the following chunk in the console to install these packages
install.packages("curl")
install.packages("renv")
install.packages("styler")
install.packages("usethis")
install.packages("tidyverse")
install.packages("readxl")Configure Run the following chunk in the console to configure RStudio correctly
usethis::use_rstudio_preferences(
check_arguments_to_r_function_calls = TRUE,
check_for_updates = FALSE,
check_unexpected_assignment_in_function_call = TRUE,
default_project_location = Sys.getenv("R_USER"),
git_exe_path = normalizePath(Sys.which("git"), "/"),
highlight_r_function_calls = TRUE,
jobs_tab_visibility = "shown",
load_workspace = FALSE,
pdf_previewer = "none",
restore_last_project = FALSE,
save_files_before_build = TRUE,
save_workspace = "never",
show_diagnostics_other = TRUE,
source_with_echo = TRUE,
style_diagnostics = TRUE,
syntax_color_console = TRUE,
use_secure_download = FALSE,
warn_variable_defined_but_not_used = TRUE,
windows_terminal_shell = "win-git-bash",
rainbow_parentheses = TRUE
)
rstudioapi::executeCommand("restartR")