Skip to content
Course Notes: Introduction to R
Course Notes
Use this workspace to take notes, store code snippets, or build your own interactive cheatsheet! For courses that use data, the datasets will be available in the datasets folder.
# Import any packages you want to use here
Take Notes
Add notes here about the concepts you've learned and code cells with code you want to keep.
Add your notes here
# Lesson 1: How R Works?
# Calculate 3 + 4
3 + 4
# Calculate 6 + 12
6 + 12
# Lesson 2: How R Works?
# An addition
5 + 5
# A subtraction
5 - 5
# A multiplication
3 * 5
# A division
(5 + 5) / 2
# Exponentiation
2^5
# Modulo
28%%6
# Lesson on Matrices
# all_wars_matrix is available in your workspace
all_wars_matrix
# Select the non-US revenue for all movies
non_us_all <- all_wars_matrix[,2]
# Average non-US revenue
mean(non_us_all)
# Select the non-US revenue for first two movies
non_us_some <- all_wars_matrix[1:2,2:2]
# Average non-US revenue for first two movies
mean(non_us_some)