Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Numbers | Vectors
TEST R COURSE

Sveip for å vise menyen

book
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,

12
typeof(10) # Example of double type typeof(10L) # Example of integer type
copy

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.

Oppgave

Swipe to start coding

  1. Assign the current year's value to the variable year. Make this variable integer type by using L.
  2. Output type of newly created variable year.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 2
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

close

Awesome!

Completion rate improved to 12.5

book
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,

12
typeof(10) # Example of double type typeof(10L) # Example of integer type
copy

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.

Oppgave

Swipe to start coding

  1. Assign the current year's value to the variable year. Make this variable integer type by using L.
  2. Output type of newly created variable year.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

close

Awesome!

Completion rate improved to 12.5

Sveip for å vise menyen

some-alt