Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Type Conversion | Basic Data Types and Vectors
R Introduction: Part I
course content

Conteúdo do Curso

R Introduction: Part I

R Introduction: Part I

1. Basic Syntax and Operations
2. Basic Data Types and Vectors
3. Factors

bookType Conversion

Indeed, while you can directly create integers in R by appending L to a number, converting existing values to integers requires a different approach. Simply appending L will cause an error, as demonstrated in the example below:

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

Certainly, that did not achieve the intended result.

Luckily, R simplifies the conversion process with straightforward functions like as.double(), as.integer(), and as.complex(). The function names are quite self-explanatory!

Numerical types follow a sort of 'hierarchy' where each integer can be converted to a double or a complex number, and each double can become a complex number. However, converting a double to an integer will result in truncation, not rounding, of the number to its integer component.

Give these functions a try!

Tarefa
test

Swipe to show code editor

  1. Convert the number 9.85 to an integer.
  2. Convert the integer 42, created with L, to a double.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 3
toggle bottom row

bookType Conversion

Indeed, while you can directly create integers in R by appending L to a number, converting existing values to integers requires a different approach. Simply appending L will cause an error, as demonstrated in the example below:

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

Certainly, that did not achieve the intended result.

Luckily, R simplifies the conversion process with straightforward functions like as.double(), as.integer(), and as.complex(). The function names are quite self-explanatory!

Numerical types follow a sort of 'hierarchy' where each integer can be converted to a double or a complex number, and each double can become a complex number. However, converting a double to an integer will result in truncation, not rounding, of the number to its integer component.

Give these functions a try!

Tarefa
test

Swipe to show code editor

  1. Convert the number 9.85 to an integer.
  2. Convert the integer 42, created with L, to a double.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 3
toggle bottom row

bookType Conversion

Indeed, while you can directly create integers in R by appending L to a number, converting existing values to integers requires a different approach. Simply appending L will cause an error, as demonstrated in the example below:

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

Certainly, that did not achieve the intended result.

Luckily, R simplifies the conversion process with straightforward functions like as.double(), as.integer(), and as.complex(). The function names are quite self-explanatory!

Numerical types follow a sort of 'hierarchy' where each integer can be converted to a double or a complex number, and each double can become a complex number. However, converting a double to an integer will result in truncation, not rounding, of the number to its integer component.

Give these functions a try!

Tarefa
test

Swipe to show code editor

  1. Convert the number 9.85 to an integer.
  2. Convert the integer 42, created with L, to a double.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Indeed, while you can directly create integers in R by appending L to a number, converting existing values to integers requires a different approach. Simply appending L will cause an error, as demonstrated in the example below:

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

Certainly, that did not achieve the intended result.

Luckily, R simplifies the conversion process with straightforward functions like as.double(), as.integer(), and as.complex(). The function names are quite self-explanatory!

Numerical types follow a sort of 'hierarchy' where each integer can be converted to a double or a complex number, and each double can become a complex number. However, converting a double to an integer will result in truncation, not rounding, of the number to its integer component.

Give these functions a try!

Tarefa
test

Swipe to show code editor

  1. Convert the number 9.85 to an integer.
  2. Convert the integer 42, created with L, to a double.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 2. Capítulo 3
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt