ComeçarComece de graça

Relational practice

In the video, Lore taught you all about different types of relational operators. For reference, here they are again:

  • > : Greater than
  • >=: Greater than or equal to
  • < : Less than
  • <=: Less than or equal to
  • ==: Equality
  • !=: Not equal

These relational operators let us make comparisons in our data. If the equation is true, then the relational operator will return TRUE, otherwise it will return FALSE.

apple <- 45.46
microsoft <- 67.88

apple <= microsoft
[1] TRUE
hello <- "Hello world"

# Case sensitive!
hello == "hello world"
[1] FALSE

micr and apple stock prices and two dates, today and tomorrow, have been created for you.

Este exercício faz parte do curso

Intermediate R for Finance

Ver curso

Instruções do exercício

  • Is apple larger than micr?
  • Check to see if apple and micr are not equal using !=.
  • Is tomorrow less than today?

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Stock prices
apple <- 48.99
micr <- 77.93

# Apple vs. Microsoft
___

# Not equals
___

# Dates - today and tomorrow
today <- as.Date(Sys.Date())
tomorrow <- as.Date(Sys.Date() + 1)

# Today vs. Tomorrow
___
Editar e executar o código