Certainly! In R, numbers are values that represent numerical quantities. Here's a simple explanation with examples:
Numeric numbers in R can be integers (whole numbers) or decimals (floating-point numbers).
Integers are whole numbers without any decimal or fractional part.
Example
x <- 10
Decimals, also known as floating-point numbers, are numbers with a decimal point.
Example
y <- 3.14
You can use the class()
function to check the data type of a number.
Example
class(x) # This will return "numeric"
class(y) # This will also return "numeric"
You can perform various mathematical operations on numbers in R, such as addition, subtraction, multiplication, and division.
Example
# Addition
3 + 5
# Subtraction
10 - 2
# Multiplication
4 * 6
# Division
20 / 5
Numbers are fundamental in R for performing calculations, storing quantities, and representing numerical data.