Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Logical Type | Section
Practice
Projects
Quizzes & Challenges
Visat
Challenges
/
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.
Tehtävä

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.

Ratkaisu

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 14
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

close

bookLogical Type

Pyyhkäise näyttääksesi valikon

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.
Tehtävä

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.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 14
single

single

some-alt