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.
Like the 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.
RStudio is what we will focus on using in this course. You will not only love it from the very beginning but as you advance in your skills you will not run out of reasons to love RStudio.
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.
The source window which is highlighted in red is just like the script window in base R. However now instead of just a script you can create R Notebooks which are similar to many other programming and science related notebooks. You can also create R Markdown documents. Markdown is an easy to use language that can create html documents. We will learn how to create these later on in this course. A benefit of both R Notebooks and R Markdown documents is that they not only can display your code but they can have tables, graphs, figures, text and even are able to publish from these.
The environment window is where you can see a list of all available data and functions. It also allows for you to quickly see what the variables in your dataset are. On top of this the environment window also has tabs for:
This is the exact same console that you see in Base R. This window will also display results from your R Markdown documents when you create html, pdf or other documents from them.
The final pane in the RStudio window is the files pane. This can allow for easy access to your files. On top of this you can see previews of plots and documents that you are creating. This also has a built in help window. In base R when you search for help it takes you out of R and to a web-browser. In RStudio you can have the help right next to the code you are writing.