Skip to content

Commit f0ed80b

Browse files
Also clarify how fill= works in locf
1 parent 038ae8f commit f0ed80b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

man/nafill.Rd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ setnafill(x, type=c("const","locf","nocb"), fill=NA, nan=NA, cols=seq_along(x))
1616
\arguments{
1717
\item{x}{ Vector, list, data.frame or data.table of numeric columns. }
1818
\item{type}{ Character, one of \emph{"const"}, \emph{"locf"} or \emph{"nocb"}. Defaults to \code{"const"}. }
19-
\item{fill}{ Double or integer, value to be used to fill. }
19+
\item{fill}{ Numeric value to be used to replace missing observations. See examples. }
2020
\item{nan}{ Either \code{NaN} or \code{NA}; if the former, \code{NaN} is treated as distinct from \code{NA}, otherwise, they are treated the same during replacement. See Examples. }
2121
\item{cols}{ Numeric or character vector specifying columns to be updated. }
2222
}
@@ -37,6 +37,10 @@ x = c(1, NA, NaN, 3, NaN, NA, 4)
3737
nafill(x, "locf")
3838
nafill(x, "locf", nan=NaN)
3939

40+
# fill= applies to any leftover NA
41+
nafill(c(NA, x), "locf")
42+
nafill(c(NA, x), "locf", fill=0)
43+
4044
dt = data.table(v1=x, v2=shift(x)/2, v3=shift(x, -1L)/2)
4145
nafill(dt, "nocb")
4246

0 commit comments

Comments
 (0)