Missing Values

In Sailr script, missing values are written as dot(.) for missing numbers (= integer + floating point numbers), and are written as empty strings ("") for missing strings. On the other hand, When importing data from R, NA's are dealt as missing values in DataSailr.

Therefore, if you need to check whether the value is missing or not, you need to compare it with .(dot) or ""(empty string). Also if you want to assign missing values to variable, you need to assgign . for number variables (integer + floating point number), and "" for string varaibels.

Examples: extract rows that do not have missing values.

df = data.frame( id=c(1 ,2 ,3 ,4, 5, 6, 7 , 8), math=c(5, 4, 5, 3, NA, 2, 5, NA), english=c(5, 5, 4, 3, 3, 4, 4, NA))
code = '
id = id
if(math == .){ // If math is missing value
  discard!() // discard the row
}
if(english == .){ // If english is missing value
  discard!() // discard the row
}
'

Caution: at current version (v0.8.6), if nothing is assigned, there will be no dataframe generated. In this case the first line "id = id" prevents this behavior.

library(datasailr)
sail(df, code)
##   id math english
## 1  1    5       5
## 2  2    4       5
## 3  3    5       4
## 4  4    3       3
## 6  6    2       4
## 7  7    5       4