Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Logical Type | Section
Essential R Programming for Absolute Beginners - 1768563985826

bookLogical Type

Note
Definition

Logical data type can store only two values: TRUE (or T) and FALSE (or F). These values are case-sensitive and are used to evaluate conditions and expressions.

Comparisons

Comparisons such as equality or greater-than tests produce logical results. These results are always either TRUE or FALSE.

Example

12
2 > 1 5 == 10
copy

Type Conversions

  • Number into logical: 0 becomes FALSE, while any non-zero number becomes TRUE;
  • String into logical:
    • 'F', 'false', 'False', 'FALSE' convert to FALSE;
    • 'T', 'true', 'True', 'TRUE' convert to TRUE;
    • Other values are converted into NA;
  • Logical into number: FALSE becomes 0 and TRUE becomes 1.
Tarefa

Swipe to start coding

  1. Assign the result of the expression 19*54 > 76*13 to the variable logic.
  2. Show the value of the logic variable.
  3. Show the data type of the logic variable.
  4. Convert the logic variable to an integer and show the result.

Avoid using the print() function.

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 14
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

close

bookLogical Type

Deslize para mostrar o menu

Note
Definition

Logical data type can store only two values: TRUE (or T) and FALSE (or F). These values are case-sensitive and are used to evaluate conditions and expressions.

Comparisons

Comparisons such as equality or greater-than tests produce logical results. These results are always either TRUE or FALSE.

Example

12
2 > 1 5 == 10
copy

Type Conversions

  • Number into logical: 0 becomes FALSE, while any non-zero number becomes TRUE;
  • String into logical:
    • 'F', 'false', 'False', 'FALSE' convert to FALSE;
    • 'T', 'true', 'True', 'TRUE' convert to TRUE;
    • Other values are converted into NA;
  • Logical into number: FALSE becomes 0 and TRUE becomes 1.
Tarefa

Swipe to start coding

  1. Assign the result of the expression 19*54 > 76*13 to the variable logic.
  2. Show the value of the logic variable.
  3. Show the data type of the logic variable.
  4. Convert the logic variable to an integer and show the result.

Avoid using the print() function.

Solução

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 1. Capítulo 14
single

single

some-alt