Get startedGet started for free

Your first R script

Welcome! In the script to the right you will type R code to solve the exercises. When you hit the Submit Answer button, every line of code in the script is executed by R and you get a message that indicates whether or not your code was correct. The output of your submission is shown in the R console.

You can also execute code directly in the R Console. When you type in the console, your submission will not be checked for correctness! Try, for example, to type in 3 + 4 and hit Enter. R should return [1] 7.

This exercise is part of the course

Introduction to R for Finance

View Course

Exercise instructions

  • An addition example has already been created for you.
  • Add another line of code in the script to calculate the difference of 6 and 4.
  • Note: Check out the # symbol in the script! This denotes a comment in your code. Comments are a great way to document your code, and are not run when you submit your answer.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Addition!
3 + 5

# Subtraction!
Edit and Run Code