From d7b8b7e67aeefd630c3e6b8d6310b8a9ceffc772 Mon Sep 17 00:00:00 2001 From: Tanguy BARTHELEMY Date: Thu, 22 May 2025 11:58:06 +0200 Subject: [PATCH 1/2] update documentation of lm (subset argument) --- src/library/stats/man/lm.Rd | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/library/stats/man/lm.Rd b/src/library/stats/man/lm.Rd index ff05afabffb..424d529f5a9 100644 --- a/src/library/stats/man/lm.Rd +++ b/src/library/stats/man/lm.Rd @@ -35,10 +35,9 @@ lm(formula, data, subset, weights, na.action, typically the environment from which \code{lm} is called.} \item{subset}{an optional vector specifying a subset of observations - to be used in the fitting process. (See additional details about how - this argument interacts with data-dependent bases in the - \sQuote{Details} section of the \code{\link{model.frame}} - documentation.)} + to be used in the fitting process. (See additional details about how + this argument interacts with data-dependent bases under \sQuote{Details} + below.) \item{weights}{an optional vector of weights to be used in the fitting process. Should be \code{NULL} or a numeric vector. @@ -132,6 +131,10 @@ lm(formula, data, subset, weights, na.action, All of \code{weights}, \code{subset} and \code{offset} are evaluated in the same way as variables in \code{formula}, that is first in \code{data} and then in the environment of \code{formula}. + Note that values calculated inside the formula, such as \code{mean(x)}, + are evaluated before subsetting - which may lead to unexpected results + if used with \code{subset}. For more information see the + \sQuote{Details} section of the \code{\link{model.frame}}. } \value{ \code{lm} returns an object of \code{\link{class}} \code{"lm"} or for From 3ecaa12b1d308ff7860c2090bc95dc12984ea89f Mon Sep 17 00:00:00 2001 From: Tanguy Barthelemy Date: Thu, 22 May 2025 16:50:54 +0200 Subject: [PATCH 2/2] Forgot to end a bracket --- src/library/stats/man/lm.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/stats/man/lm.Rd b/src/library/stats/man/lm.Rd index 424d529f5a9..0d3b4b52d0a 100644 --- a/src/library/stats/man/lm.Rd +++ b/src/library/stats/man/lm.Rd @@ -37,7 +37,7 @@ lm(formula, data, subset, weights, na.action, \item{subset}{an optional vector specifying a subset of observations to be used in the fitting process. (See additional details about how this argument interacts with data-dependent bases under \sQuote{Details} - below.) + below.)} \item{weights}{an optional vector of weights to be used in the fitting process. Should be \code{NULL} or a numeric vector.