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.
Cet exercice fait partie du cours
Intermediate R for Finance
Instructions
- Is
applelarger thanmicr? - Check to see if
appleandmicrare not equal using!=. - Is
tomorrowless thantoday?
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# 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
___