R | The School of Code

Settings

Appearance

Choose a typography theme that suits your style

R

Learn R for statistical computing and data analysis.

1

Hello World

R uses print() or cat() to output text. R is a language designed for statistical computing and graphics.

Example

Run this example to see how it works and then try the exercise.

example.r
Loading...
Output
Click "Run" to see the example in action...
Exercise

Your task: Print "Hello, World!" using the print() function

main.r
Loading...
Output
Click "Run" to execute your code...
Quiz

What symbol starts a comment in R?

SUMMARY

In this section, you learned how to print output to the console. Next, you'll learn how to declare variables and assign values.

2

Variables and Assignment

R uses <- (preferred) or = for assignment. Variables don’t need type declarations.

Example

Run this example to see how it works and then try the exercise.

example.r
Loading...
Output
Click "Run" to see the example in action...
Exercise

Your task: Create variables: name, age, is_learning using <-

main.r
Loading...
Output
Click "Run" to execute your code...
Quiz

What is the preferred assignment operator in R?

SUMMARY

In this section, you learned how to declare variables and assign values. Next, you'll learn how to work with different data types.

3

Arithmetic Operations

R has basic types: numeric, character, logical, integer, and complex. Use class() to check type.

Example

Run this example to see how it works and then try the exercise.

example.r
Loading...
Output
Click "Run" to see the example in action...
Exercise

Your task: Create variables of different types and print their classes

main.r
Loading...
Output
Click "Run" to execute your code...
Quiz

How do you create an integer in R?

SUMMARY

In this section, you learned how to work with different data types. Next, you'll learn how to work with vectors to store multiple values.

Unlock 10 More Lessons

You've completed the free preview! Upgrade to Pro to access all 12 lessons in this course, plus advanced projects and certificates.

Locked lessons:
  • Vectors
  • Conditionals
  • For Loops
  • While Loops
  • Functions
  • Lists
  • Data Frames
  • Apply Functions
  • Final Project: Student Performance Analysis
Hello World 1
Variables and Assignment 2
Arithmetic Operations 3
Unlock 10 more lessons Access all content with Pro
Upgrade
Vectors 4 Conditionals 5 For Loops 6 While Loops 7 Functions 8 Lists 9 Data Frames 10 Apply Functions 11 Final Project: Student Performance Analysis 12

Reset Progress?

Are you sure you want to reset all progress for this course? This action cannot be undone.