Numbers
You got "double"
as an output in the last chapter, despite the number 10
being an integer. Let's investigate it.
What types can numeric values in R be? Let's remind. These are:
numeric
/double
- real numbers.integer
- integer numbers.complex
- complex numbers.
But in the last chapter, you got "double"
for an integer number. How to make R recognize integer numbers? One of the ways is to simply put L
at the end of the number. For example,
12typeof(10) # Example of double type typeof(10L) # Example of integer type
This script will return the next output:
[1] "double"
[1] "integer"
Why do we even need to differentiate 10
and 10L
values? The answer is memory consumption - storing integers is 'easier' for computer memory.
Swipe to start coding
- Assign the current year's value to the variable
year
. Make this variable integer type by usingL
. - Output type of newly created variable
year
.
Soluzione
Grazie per i tuoi commenti!
single
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
Awesome!
Completion rate improved to 12.5
Numbers
Scorri per mostrare il menu
You got "double"
as an output in the last chapter, despite the number 10
being an integer. Let's investigate it.
What types can numeric values in R be? Let's remind. These are:
numeric
/double
- real numbers.integer
- integer numbers.complex
- complex numbers.
But in the last chapter, you got "double"
for an integer number. How to make R recognize integer numbers? One of the ways is to simply put L
at the end of the number. For example,
12typeof(10) # Example of double type typeof(10L) # Example of integer type
This script will return the next output:
[1] "double"
[1] "integer"
Why do we even need to differentiate 10
and 10L
values? The answer is memory consumption - storing integers is 'easier' for computer memory.
Swipe to start coding
- Assign the current year's value to the variable
year
. Make this variable integer type by usingL
. - Output type of newly created variable
year
.
Soluzione
Grazie per i tuoi commenti!
Awesome!
Completion rate improved to 12.5single