Ben Dickins
R is a free software environment for statistical computing and graphics. It compiles and runs on a wide variety of operating systems including Windows, MacOS and assorted linux distributions.
RStudio is a set of integrated tools designed to help you be more productive with R. This is referred to as an Integrated Development Environment or IDE. Alternative IDEs for R include RKWard and even Visual Studio Code when properly configured.
If you have administrative access to the computer you are using you should be able to install the R and RStudio programs. If you do not have admin access you can try RStudio Cloud.
TO INSTALL
R
RStudio
RStudio Cloud
GO TO
R homepage and follow the links to CRAN (Comprehensive R Access Network), selecting a mirror site near your current location,
RStudio.com and choose the open source “Desktop edition”,
RStudio Cloud and sign up for a free account.
|
The text-based R environment is known as the console and is accessible via:
A Terminal Emulator
R Standalone App
Here is what the RStudio Graphical User Interface (GUI) looks like:
Getting help from R’s built-in facility. For a given function “makecupcake” you can invoke the help pages using the ?
character. For this example you would type the following into the console:
Note that the console has a flashing cursor just to the right of a >
character. The >
is known as the prompt command and it means that R is expecting you to input a command.
Let’s try this for a more informative function:
What did you get when you did this in RStudio?
Do you need more information or can’t you find what you are looking for? Use ??
:
Also you can obtain more details on features specified by special characters:
We’ll try some of these in the next slide.
Let’s try a couple:
Let’s try something new (and please don’t be frustrated by the result!). Type the following command:
What happened?
To get an example of the use of a function (or topic), you can try:
Have a go yourself:
Try the same for the sd
function. Can you figure out what it does?
If a command is not complete at the end of a line, R will give a different prompt, by default this is +
.
You will experience this a lot. So be careful with opening and closing your brackets, for example try:
You will see the prompt transform into a +
meaning that it expects more input. To get out of this you can do one of two things:
)
), orOption 2 will cancel the command, but will rescue you from bracket meltdown.