Skip to content

Commit

Permalink
modified printed output to reflect poly order
Browse files Browse the repository at this point in the history
  • Loading branch information
mgimond committed Jul 23, 2024
1 parent e5b408b commit d81061c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
19 changes: 13 additions & 6 deletions R/eda_lm.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@
#' line to the data. \code{rlm} arguments can be passed as a list via the
#' \code{rlm.d} argument.
#'
#' @return Returns residuals, intercept and slope from an OLS fit.
#' @return Returns residuals, intercept and coefficient(s) from an OLS
#' fit if \code{reg = TRUE}. Returns \code{NULL} otherwise.
#'
#' \itemize{
#' \item \code{residuals}: Regression model residuals
#' \item \code{a}: Intercept
#' \item \code{b}: Slope}
#' \item \code{b}: Polynomial coefficient(s)}
#'
#' @seealso \code{\link[graphics]{plot}} and \code{\link[stats]{loess.smooth}}
#' functions
Expand Down Expand Up @@ -279,8 +280,14 @@ eda_lm <- function(dat, x, y, xlab = NULL, ylab = NULL, px = 1, py = 1,

# Reset plot parameters
par(.pardef)
out_coef <- coef(M)
names(out_coef) <- c("int", paste0(xlab, "^", 1:poly))
print(out_coef)
invisible(list(residuals = residuals(M), a = coef(M)[1], b = coef(M)[2]))

# Output residuals and coefficients if regression is set to TRUE
if(reg == TRUE) {
out_coef <- coef(M)
names(out_coef) <- c("int", paste0(xlab, "^", 1:poly))
print(out_coef)
invisible(list(residuals = residuals(M), a = out_coef[1], b = out_coef[-1]))
} else {
print(NULL)
}
}
5 changes: 3 additions & 2 deletions docs/reference/eda_lm.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/eda_lm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d81061c

Please sign in to comment.