Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Converting | Vectors
TEST R COURSE
course content

Contenido del Curso

TEST R COURSE

TEST R COURSE

1. Basic Syntax and Operations
2. Vectors

bookConverting

Good! Now you can convert numbers into integers while creating. But what if you want to convert specific results? Putting L will not help and raise an error, like in the example below.

123
# Some number num <- 20 numL # Trying using L for converting
copy

The output of the script above is:

Surely, not what we were wanted to do.

R provides us with very simple and convenient functions to convert variables/values into different formats. These are as.double(), as.integer(), as.complex(). See, the functions' names are intuitive!

There is a 'hierarchy' within numerical types, i.e., each integer number can be converted into double and complex, and each double can be converted into complex. complex numbers can not be converted into either double, either integer type (unless the imaginary part is 0). double numbers can be converted into integer, but this will not round, but truncate to integer part.

Try these functions by yourself!

Tarea

  1. Convert the number 9.85 into integer.
  2. Convert the number 23.8 into complex.
  3. Convert the integer number 42 created by using L into double.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 4
toggle bottom row

bookConverting

Good! Now you can convert numbers into integers while creating. But what if you want to convert specific results? Putting L will not help and raise an error, like in the example below.

123
# Some number num <- 20 numL # Trying using L for converting
copy

The output of the script above is:

Surely, not what we were wanted to do.

R provides us with very simple and convenient functions to convert variables/values into different formats. These are as.double(), as.integer(), as.complex(). See, the functions' names are intuitive!

There is a 'hierarchy' within numerical types, i.e., each integer number can be converted into double and complex, and each double can be converted into complex. complex numbers can not be converted into either double, either integer type (unless the imaginary part is 0). double numbers can be converted into integer, but this will not round, but truncate to integer part.

Try these functions by yourself!

Tarea

  1. Convert the number 9.85 into integer.
  2. Convert the number 23.8 into complex.
  3. Convert the integer number 42 created by using L into double.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 4
toggle bottom row

bookConverting

Good! Now you can convert numbers into integers while creating. But what if you want to convert specific results? Putting L will not help and raise an error, like in the example below.

123
# Some number num <- 20 numL # Trying using L for converting
copy

The output of the script above is:

Surely, not what we were wanted to do.

R provides us with very simple and convenient functions to convert variables/values into different formats. These are as.double(), as.integer(), as.complex(). See, the functions' names are intuitive!

There is a 'hierarchy' within numerical types, i.e., each integer number can be converted into double and complex, and each double can be converted into complex. complex numbers can not be converted into either double, either integer type (unless the imaginary part is 0). double numbers can be converted into integer, but this will not round, but truncate to integer part.

Try these functions by yourself!

Tarea

  1. Convert the number 9.85 into integer.
  2. Convert the number 23.8 into complex.
  3. Convert the integer number 42 created by using L into double.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Good! Now you can convert numbers into integers while creating. But what if you want to convert specific results? Putting L will not help and raise an error, like in the example below.

123
# Some number num <- 20 numL # Trying using L for converting
copy

The output of the script above is:

Surely, not what we were wanted to do.

R provides us with very simple and convenient functions to convert variables/values into different formats. These are as.double(), as.integer(), as.complex(). See, the functions' names are intuitive!

There is a 'hierarchy' within numerical types, i.e., each integer number can be converted into double and complex, and each double can be converted into complex. complex numbers can not be converted into either double, either integer type (unless the imaginary part is 0). double numbers can be converted into integer, but this will not round, but truncate to integer part.

Try these functions by yourself!

Tarea

  1. Convert the number 9.85 into integer.
  2. Convert the number 23.8 into complex.
  3. Convert the integer number 42 created by using L into double.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 2. Capítulo 4
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
some-alt