Ways to Use R
When you install R you will see what is called base R.
The R console is the window on the left. You can type R code into this and then it runs and returns the output in the same window. You must be mindful because this does not save your work and does not provide any helpful tools.
The R Script is the window on the right. If you are used to Stata you can think of this as a
do file or in SAS this is the code file that you run. In this manner we can save our work and comment it in R.
do file and
.sas file, none of the output is included in this and we must run it each time in order to display our results. Then we must copy our results into an external editor in order to use them.
You have currently installed RStudio Desktop, however there is a server version available which allows for shared coding projects and a central R installation so that users do not need to manage things by themselves.
We will begin to explore the RStudio windows now.
History: Displays all previous code run in the console.
Spark: You can integrate RStudio with a Apache Spark installation to work with large data.
Git: You can use github for a version tracking of every project.
Files and Help Pane
Getting Started with `swirl`:
1) Click <a href = “https://github.com/sullivanstatistics/swirl_courses/archive/master.zip”here</a> to download the file `swirl_courses-master.zip`.
2) Enter the following from the R console, substituting the correct file path to your downloaded file and the name of your desired course:
For example, if you download the zip file to `~/Downloads/swirl_courses-master.zip`, then the following command will install the R Programming course.
Please note that course names are case sensitive!
On Your Own: Swirl Practice
In order to learn R you must do R. Follow the steps below in your RStudio console:
1. Run this command to pick the course:
You will be promted to choose a course. Type whatever number is in front of 01 Getting Started. This will then take you to a menu of lessons. For now we will just use lesson 1. Type 1 to choose Workspace and Files then follow all the instructions until you are finished.
Once you are finished with the lesson come back to this course and continue.