Not!
One last operator to introduce is ! or, Not. You have already seen a similar operator, !=, so you might be able to guess what it does. Add ! in front of a logical expression, and it will flip that expression from TRUE to FALSE (and vice versa).
!TRUE
[1] FALSE
apple <- c(120.00, 120.08, 119.97, 121.88)
!(apple < 121)
[1] FALSE FALSE FALSE TRUE
The stocks data frame is available for you to use.
Bu egzersiz
Intermediate R for Finance
kursunun bir parçasıdırEgzersiz talimatları
- Use
!and a relational operator to know whenibmis not above176. - A new vector,
missing, has been created, which contains missing data. - The function
is.na()checks for missing data. Useis.na()onmissing. - Suppose you are more interested in where you are not missing data.
!can show you this. Use!in front ofis.na()to show positions where you do have data.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# IBM range
___
# Missing data
missing <- c(24.5, 25.7, NA, 28, 28.6, NA)
# Is missing?
___
# Not missing?
___