# Save current packages and their versions to object called ip
<- installed.packages()
ip
ip
# Save the object as an .rds file
saveRDS(ip, "CurrentPackages.rds")
Prerequisites
If you do not have R or RStudio installed on your computer, then follow the install instructions below.
If you already have R or RStudio installed on your computer, then is it recommended to Update Software for this course.
Install Software
Install R
First you need to download the latest version of R from their website https://www.r-project.org
Select CRAN on the left, just under Download
Select the first option under 0-Cloud
Select the download option depending on your computer
Select the base installation (for Windows) or the Latest Release (for Mac)
Open and Run the installation file
Install RStudio
The easiest way to interact with R is through the RStudio environment. To do this you need to download RStudio
- Select the Free version of RStudio Desktop
- Select the download option depending on your computer
Update Software
Update R
If you already have R installed, but want to update it to the most current version follow these steps.
Warning: When updating R (not RStudio), it may remove all packages you have installed
First check what version of R you have installed.
Open RStudio
In the console window you will see the R version you are running (e.g., R version 4.1.0)
If you have an R version older than 4.0.0 than you need to update R.
Run the following lines of code in your console window. This is an easy way to re-install all your currently installed packages. This step will save a list of packages to re-install later.
Exit out of all R or RStudio windows
Download and install the latest version of R (see the section on installing R above)
Open RStudio
Check if your previously installed packages are installed using the Packages tab in the bottom right window
If you need to re-install your previous packages, then run the following lines of code
# After updating R, load the file and reinstall packages
<- readRDS("CurrentPackages.rds")
ip
install.packages(ip[,1])
Update RStudio
Go to Help -> Check for Updates
Getting to Know RStudio
While R is the actual programming software that executes the code, RStudio is an environment for interacting with R, writing R scripts, managing and organizing projects, and much more. When you open RStudio, it will open a window to the R console within the RStudio environment.
Go ahead an open the RStudio application on your computer.
When you open a fresh session of RStudio there are 3 window panes open. The Console window, the Environment window, and the Files window. Go ahead and navigate to File -> New File -> R Script. You should now see something similar to the image below
There are 4 window panes and each one has it’s own set of tabs associated with it:
The Console window (the bottom left window pane) is where code is executed and output is displayed.
The Source window (the top left window pane) is where you will write your code to create a script file. When you open a new script file you will see a blank sheet where you can start writing the script. When you execute lines of code from here you will see it being executed in the Console window.
The Source window is also where you can view data frames you have just imported or created. In the image above, notice the different tabs in the Source window. There are two “Untitled” script files open and one data frame called ‘data’.
The Environment window (top right window pane) is where you can see any data frames, variables, or functions you have created. Go ahead and type the following in your Console window and hit enter.
<- "hello" welcome_message
You should now see the variable welcome_message
in the Environment window pane
- The Files window (the bottom right window pane) is where you can see your computer’s directories, plots you create, manage packages, and see help documentation.
You can also Customize RStudio settings and appearances.
Customizing RStudio
Coming soon…