Description Usage Arguments Details Value Examples
identify missing rows for model/formula.
| 1 | get_valid_rows(model, data)
 | 
| model | a formula or an output of lm or glm | 
| data | the data.frame supposed to be used in modelling | 
Data often contains missing values and lm() or glm() often skip those rows.
This function is to identify which rows that lm() or glm() skips.
a boolean vector with same length as the number of rows of data, with TRUE if a row has full data for the modelling and FALSE if not.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | model = lm(price ~ carat, head(ggplot2::diamonds,1000))
data = head(ggplot2::diamonds,10)
# so observation 1, 4, 7 will be not valid rows
data[c(1,4,7),"price"] = NA
data
get_valid_rows(model,data)
# error message as no "price" is found in the data
data[,"price"] = NULL
tryCatch(get_valid_rows(model,data),
         error = function(x){
           print(x)
         })
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.