diff --git a/man/frolladapt.Rd b/man/frolladapt.Rd index 2c4d45e7a..01068081a 100644 --- a/man/frolladapt.Rd +++ b/man/frolladapt.Rd @@ -35,6 +35,19 @@ dt n34 = frolladapt(idx, c(small=3, big=4), give.names=TRUE) n34 dt[, frollmean(value, n34, adaptive=TRUE, give.names=TRUE)] + +## panel data: rolling mean within groups, respecting irregular date gaps +## equivalent to Stata: rangestat (mean) rollmean3 = sales, int(date -2 0) by(firm) +dt = data.table( + firm = rep(c("A", "B"), each = 4), + date = as.Date(c("2020-01-01", "2020-01-02", "2020-01-05", "2020-01-06", + "2020-01-01", "2020-01-03", "2020-01-04", "2020-01-07")), + sales = c(10, 12, 15, 13, 20, 22, 18, 25) +) +setorder(dt, firm, date) +dt[, rollmean3 := frollmean(sales, frolladapt(date, n=3L, partial=TRUE), + adaptive=TRUE), by = firm] +dt } \seealso{ \code{\link{froll}}, \code{\link{frollapply}} diff --git a/man/melt.data.table.Rd b/man/melt.data.table.Rd index 40506eb6a..46f85611d 100644 --- a/man/melt.data.table.Rd +++ b/man/melt.data.table.Rd @@ -56,8 +56,7 @@ more than once and the same column can be both as id and measure variables. variables. When all \code{measure.vars} are not of the same type, they'll be coerced -according to the hierarchy \code{list} > \code{character} > \code{numeric > -integer > logical}. For example, if any of the measure variables is a +according to the hierarchy \code{list} > \code{character} > \code{numeric} > \code{integer} > \code{logical}. For example, if any of the measure variables is a \code{list}, then entire value column will be coerced to a list. From version \code{1.9.6}, \code{melt} gains a feature with \code{measure.vars} diff --git a/man/nafill.Rd b/man/nafill.Rd index 90c4b1c5c..659d371e1 100644 --- a/man/nafill.Rd +++ b/man/nafill.Rd @@ -14,7 +14,7 @@ nafill(x, type=c("const", "locf", "nocb"), fill=NA, nan=NA) setnafill(x, type=c("const", "locf", "nocb"), fill=NA, nan=NA, cols=seq_along(x)) } \arguments{ - \item{x}{ Vector, list, data.frame or data.table of logical, numeric or character columns. } + \item{x}{ Vector, list, data.frame or data.table of logical, numeric, character, or factor columns. } \item{type}{ Character, one of \emph{"const"}, \emph{"locf"} or \emph{"nocb"}. Defaults to \code{"const"}. } \item{fill}{ Value to be used to replace missing observations. See examples. } \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. }