nafill.Rd
Fast fill missing values using constant value, last observation carried forward or next observation carried backward.
nafill(x, type=c("const","locf","nocb"), fill=NA, verbose=getOption("datatable.verbose")) setnafill(x, type=c("const","locf","nocb"), fill=NA, cols=seq_along(x), verbose=getOption("datatable.verbose"))
x | vector, list, data.frame or data.table of numeric columns. |
---|---|
type | character, one of "const", "locf" or "nocb". Defaults to |
fill | numeric or integer, value to be used to fill when |
cols | numeric or character vector specifying columns to be updated. |
verbose | logical, |
Only double and integer data types are currently supported.
A list except when the input is a vector
in which case a vector
is returned. For setnafill
the input argument is returned, updated by reference.
#> [1] NA NA 3 4 4 4 7 8 8 8#> [[1]] #> [1] 3 3 3 4 7 7 7 8 NA NA #> #> [[2]] #> [1] 1.5 1.5 1.5 1.5 2.0 3.5 3.5 3.5 4.0 NA #> #> [[3]] #> [1] 1.5 1.5 2.0 3.5 3.5 3.5 4.0 NA NA NA #>#> v1 v2 v3 #> 1: NA NA NA #> 2: NA NA 1.5 #> 3: 3 NA 2.0 #> 4: 4 1.5 2.0 #> 5: NA 2.0 2.0 #> 6: NA 2.0 3.5 #> 7: 7 2.0 4.0 #> 8: 8 3.5 4.0 #> 9: NA 4.0 4.0 #> 10: NA 4.0 4.0