Skip to content

Commit

Permalink
Corrections in autoplot.nls()
Browse files Browse the repository at this point in the history
  • Loading branch information
phgrosjean committed Nov 21, 2023
1 parent 5f8b998 commit 03c7887
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: modelit
Type: Package
Version: 1.4.1
Version: 1.4.2
Title: 'SciViews' - Statistical Models Within 'SciViews::R'
Description: Create and Use Statistical Models (Linear, General, Nonlinear, ...)
by using a SciViews::R common formula interface and label-aware functions.
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# modelit 1.4.2

- Bug correction in `autoplot.nls()`: X and Y axes were inverted. Also the deprecated `aes_string()` function is replaced with `aes()` with proper arguments.

# modelit 1.4.1

- Slight adjustments to have a space between the label and the units in equations, and to allow beta instead of beta_1 if there is no beta_0 or beta_2 in the same equations and in the tables from `tabularise()`.
Expand Down
7 changes: 4 additions & 3 deletions R/chart.nls.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class(chart.nls) <- c("function", "subsettable_type")

#' @export
#' @rdname chart.nls
#' @importFrom rlang .data
autoplot.nls <- function(object,
type = c("model", "resfitted", "qqplot", "scalelocation", "reshist",
"resautocor"), title, xlab, ylab, ..., name = deparse(substitute(object)),
Expand Down Expand Up @@ -108,9 +109,9 @@ type = c("model", "resfitted", "qqplot", "scalelocation", "reshist",
(function(nls) {
adata <- augment(nls)
ndata <- names(adata)
Y <- ndata[1]
X <- ndata[2]
chart(data = adata, aes_string(x = X, y = Y)) +
X <- as.name(ndata[1])
Y <- as.name(ndata[2])
chart(data = adata, aes(x = {{ X }}, y = {{ Y }})) + # Was: aes_string(x = X, y = Y)) +
geom_point() +
stat_function(fun = as.function(nls), col = "skyblue3", size = 1)
})(.),
Expand Down

0 comments on commit 03c7887

Please sign in to comment.