Lesson 2

Welcome to our next lesson! Up to this point, we've introduced you to assigning and printing strings in R. This lesson builds on that basic understanding by diving into *numeric values* and how to perform simple arithmetic operations.

In this lesson, you will learn how to:

- Assign numeric variables
- Perform basic arithmetic operations
- Print the results of these operations

To make things concrete, here's a sneak peek at what we'll be covering:

R`1# Assigning numeric variables 2a <- 5 3b <- 10 4 5# Basic arithmetic operations 6sum <- a + b 7difference <- b - a 8product <- a * b 9quotient <- b / a 10 11# Printing results of arithmetic operations 12print(sum) # Prints: 15 13print(difference) # Prints: 5 14print(product) # Prints: 50 15print(quotient) # Prints: 2`

By the end of this lesson, you'll be able to handle simple numeric data in R, which is a foundational skill that you'll use in more complex tasks later!

Understanding and manipulating numbers is a fundamental skill in programming. Whether you're analyzing data, creating algorithms, or building applications, you will constantly work with numbers. The ability to perform arithmetic operations and print results empowers you to solve real-world problems. For instance, if you're working with financial data, you'll need to perform operations like addition, subtraction, multiplication, and division to analyze trends and make decisions.

Exciting, right? Let's start the practice section and explore these concepts in depth.