Course Content
R Introduction: Part I
1. Basic Syntax and Operations
R Introduction: Part I
Numbers
In the previous section, we saw that the number 10
was identified as a "double"
even though it is an integer. Let's delve into this peculiarity.
R can categorize numeric values into several types, which are:
numeric
/double
- representing real numbers.integer
- for integer numbers.complex
- for numbers with both a real and an imaginary part.
Yet, in our previous exercise, 10
was classified as a "double"
. To have R recognize it as an integer, appending L
to the number is a straightforward method. For instance:
Differentiating between 10
and 10L
is important because of how memory is utilized — integers take up less space.
Task
- Assign the current year's numerical value to a variable named
year
, and ensure that it is of integer type by appendingL
. - Determine and display the type of the variable
year
.
Everything was clear?
Section 2. Chapter 2