Numbers
In the previous section, we observed 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:
double
- representing real numbers;integer
- for whole numbers;complex
- for numbers with both a real and an imaginary part.
To have R recognize 10
as an integer
instead of a double
, you can append L
to the number. Here’s how you can do it:
12typeof(10) # Example of double type typeof(10L) # Example of integer type
Differentiating between 10
and 10L
is important because of how memory is utilized — integers take up less space.
Swipe to start coding
-
Assign the current year's numerical value to a variable named
year
, and ensure that it is ofinteger
type by appendingL
. -
Determine and display the type of the
year
variable:
Solución
¡Gracias por tus comentarios!
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Awesome!
Completion rate improved to 3.85
Numbers
Desliza para mostrar el menú
In the previous section, we observed 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:
double
- representing real numbers;integer
- for whole numbers;complex
- for numbers with both a real and an imaginary part.
To have R recognize 10
as an integer
instead of a double
, you can append L
to the number. Here’s how you can do it:
12typeof(10) # Example of double type typeof(10L) # Example of integer type
Differentiating between 10
and 10L
is important because of how memory is utilized — integers take up less space.
Swipe to start coding
-
Assign the current year's numerical value to a variable named
year
, and ensure that it is ofinteger
type by appendingL
. -
Determine and display the type of the
year
variable:
Solución
¡Gracias por tus comentarios!
Awesome!
Completion rate improved to 3.85single