aboutsummaryrefslogtreecommitdiff
path: root/R/calplot.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2021-04-07 11:38:05 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2021-04-07 11:38:05 +0200
commit8596a3e82235385b5de50cc5a722ccb68247f084 (patch)
treedf17246e512751b361c571e4671842ff4d9bbb72 /R/calplot.R
parent43d58935483e0d9dda7a74c029e7d7d2adad9ed7 (diff)
Argument 'legend_x' for 'calplot'
Also, keep check and test logs in the repository.
Diffstat (limited to 'R/calplot.R')
-rw-r--r--R/calplot.R14
1 files changed, 9 insertions, 5 deletions
diff --git a/R/calplot.R b/R/calplot.R
index 6aed9c0..fd49a54 100644
--- a/R/calplot.R
+++ b/R/calplot.R
@@ -1,7 +1,8 @@
calplot <- function(object,
xlim = c("auto", "auto"), ylim = c("auto", "auto"),
- xlab = "Concentration", ylab = "Response", alpha = 0.05,
- varfunc = NULL)
+ xlab = "Concentration", ylab = "Response",
+ legend_x = "auto",
+ alpha = 0.05, varfunc = NULL)
{
UseMethod("calplot")
}
@@ -9,6 +10,7 @@ calplot <- function(object,
calplot.default <- function(object,
xlim = c("auto","auto"), ylim = c("auto","auto"),
xlab = "Concentration", ylab = "Response",
+ legend_x = "auto",
alpha=0.05, varfunc = NULL)
{
stop("Calibration plots only implemented for univariate lm objects.")
@@ -16,8 +18,9 @@ calplot.default <- function(object,
calplot.lm <- function(object,
xlim = c("auto","auto"), ylim = c("auto","auto"),
- xlab = "Concentration", ylab = "Response", alpha=0.05,
- varfunc = NULL)
+ xlab = "Concentration", ylab = "Response",
+ legend_x = "auto",
+ alpha=0.05, varfunc = NULL)
{
if (length(object$coef) > 2)
stop("More than one independent variable in your model - not implemented")
@@ -47,6 +50,7 @@ calplot.lm <- function(object,
yrange.auto <- range(c(0,pred.lim))
if (ylim[1] == "auto") ylim[1] <- yrange.auto[1]
if (ylim[2] == "auto") ylim[2] <- yrange.auto[2]
+ if (legend_x[1] == "auto") legend_x <- min(object$model[[2]])
plot(1,
type = "n",
xlab = xlab,
@@ -68,7 +72,7 @@ calplot.lm <- function(object,
} else {
matlines(newdata[[1]], conf.lim, lty = c(1, 3, 3),
col = c("black", "green4", "green4"))
- legend(min(x),
+ legend(legend_x,
max(pred.lim, na.rm = TRUE),
legend = c("Fitted Line", "Confidence Bands",
"Prediction Bands"),

Contact - Imprint