You will be using R and RStudio throughout the course both to learn the statistical concepts discussed in the textbook and also to analyze real data and come to informed conclusions. To straighten out which is which: R is the name of the programming language itself and RStudio is a convenient interface.
The RStudio window should look something like this:
The panel in the upper right contains your workspace as well as a history of the commands that you’ve previously entered. Any plots that you generate will show up in the panel in the lower right corner.
The panel on the left is where the action happens. It’s called the console.
Every time you launch RStudio, it will have the same text at the top of the console telling you the version of R that you’re running. Below that information is the prompt. As its name suggests, this prompt is really a request, a request for a command. Initially, interacting with R is all about typing commands and interpreting the output. These commands and their syntax have evolved over decades (literally) and now provide what many users feel is a fairly natural way to access data and organize, describe, and invoke statistical computations.
You can use R as a calculator. To get you started, enter the following command at the R prompt (i.e. right after >
on the console). You can either type it in manually or copy and paste it from this document.
2+2
## [1] 4
And you can save this result to an object that you can access later
= 2+2 x
Try typing x
in the console to verify that.
You can also see this new object in your environment on the upper right pane. Next time you log on to RStudio the object will still be here.
Throughout the semester you will learn about how to use R to do data analysis, and in the meantime you will be exposed to some programming. In addition, you will learn best practices for saving your code and making sure that your analysis is reproducible.
Take the course pre-assessment. How well or bad you do in this pre-assessment will NOT affect your grade. Answer what you can, if you don’t know the answer don’t guess, skip it. This will help us adjust the goals of the course, we need a real assessment of your skills. We won’t judge, I promise.
Science should be open! Here at Cornell and everywhere, this lab is released under a Creative Commons Attribution-ShareAlike 3.0 Unported.