An Overview of R Studio

The 10 minute video below walks you through using R Studio to import a data set, how to create and execute a script to analyze it, and how to create and export graphs..

alternative accessible content

 

Using R as a Calculator - Simple Math Functions and Commands in R

THe "Console" window in R Studio can be used as a calculator.

For the examples below:

Try entering the following commands in the R Console at the lower left window. You do not have to enter the comments in green. Just enter the commands in blue and hit "Enter". You should see the result written in black after the [1].

# Addition
> 7+3
[1] 10

# Subtraction
> 7-3
[1] 4

# Multiplication
> 8*7
[1] 56

# Division
> 100/50
[1] 2

# Square root
> sqrt(81)
[1] 9

# Exponents
> 9^2
[1] 81

You can execute code one step at a time in the console (lower left window), and this is useful for quick one step math calculations, but it is usually more convenient to list all of your coding statements in a script in the window at the upper left and then saving the script for future use. When you enter code into the script window at the upper left, do not begin the line with a > character. You can also execute the code from the script editing window by clicking on the "Run" tab at the top of the editing window. To save a script, click on the "File" tab at the upper left and select either Save as or Save.