CLiREN-LMS
Introduction to R for Clinical Data Management

Installing R and RStudio

6.2 Installing R and RStudio

30-45 minutes Applied Step 3 of 9
Reading 1

6.2 Installing R and RStudio

3 / 9
Before using R, learners need to understand the relationship between R and RStudio. R is the language and computational engine. RStudio is an integrated development environment that makes it easier to write, run, organize, and review R code. R can be used without RStudio, but RStudio provides a more user-friendly interface for beginners and is widely used in academic and applied research settings [@posit2024rstudio]. The first installation step is to install R from the Comprehensive R Archive Network, commonly called CRAN. CRAN provides R installers for Windows, macOS, and Linux. Once R is installed, RStudio Desktop can be installed separately. RStudio detects the installed version of R and provides a working environment with panes for scripts, console output, objects, files, plots, packages, help, and version control integration. In an institutional environment, installation may require information technology support. Some organizations restrict software installation or require approved versions. Clinical research teams should follow local information security and governance procedures, especially when working with identifiable or sensitive health data. Installing R and RStudio is not only a technical task; it is part of establishing a controlled computing environment. Teams should know where data will be stored, whether the workstation is encrypted, whether network drives are approved for research data, and whether scripts will be version controlled. It is also important to distinguish between installing software and installing packages. Installing R and RStudio is usually done once per computer or when a new version is required. Installing R packages is done from within R and may occur more often. Packages extend the base capabilities of R. For example, the tidyverse provides tools for data import, transformation, visualization, and programming using a consistent grammar [@wickham2019tidyverse]. Other packages support Excel import, data cleaning, table production, reporting, and connection to databases.
ComponentWhat it isWhy it matters in clinical data management
RThe programming language and statistical computing environmentRuns the code that imports, checks, transforms, and summarizes data
RStudioThe interface used to write and manage R codeHelps beginners organize scripts, projects, files, objects, and output
CRANMain repository for R and many R packagesProvides stable package installation for common workflows
R packageA reusable collection of functions and documentationAdds specific capabilities such as importing Excel files or cleaning names
R projectA project-level workspace managed by RStudioKeeps code, data, and outputs organized within one study folder
ScriptA text file containing R commandsDocuments the data management process so it can be rerun
For learners working on this course, a recommended installation sequence is: 1. Install R from CRAN. 2. Install RStudio Desktop from Posit. 3. Create a course practice folder. 4. Open RStudio and create a new R project inside that folder. 5. Install the packages needed for the exercises. 6. Save all practice scripts inside a `scripts` folder. 7. Keep imported raw data separate from cleaned or derived data. The installation should be tested before any course session that relies on practical R exercises. A simple test is to open RStudio, type `1 + 1` in the console, and confirm that R returns `2`. This test is simple, but it confirms that RStudio can communicate with the installed R engine. ```r 1 + 1 ``` The expected output is: ```text [1] 2 ``` This first command is not clinically meaningful, but it confirms that the environment is working. Once learners can run a command, the next step is to organize work using an R project.