Skip to content

Commit

Permalink
update bivariate
Browse files Browse the repository at this point in the history
  • Loading branch information
Kucharssim committed Sep 11, 2023
1 parent 47d745b commit 25a4694
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
26 changes: 23 additions & 3 deletions R/jaspBivariate.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#' @title Bivariate plots with optional confidence and prediction intervals.
#'
# #' @encoding UTF-8
#' @description This plot consists of three layers:
#' \enumerate{
#' \item The bivariate distribution.
#' \item Smooth line through the data displayed using [ggplot2::geom_smooth].
#' \item Prediction interval of y given x using [stats::predict.lm](assuming linear relationship), or prediction ellipse assuming bivariate normal distribution.
#' }
#' @param x Numeric vector of values on the x-axis.
#' @param x Numeric vector of values on the x-axis. `r "\u03BC"`
#' @param y Numeric vector of values on the y-axis.
#' @param group Optional grouping variable.
#' @param xName Character; x-axis label. If left empty, the name of the \code{x} object is displayed. To remove the axis label, use \code{NULL}.
Expand Down Expand Up @@ -50,7 +50,7 @@ jaspBivariate <- function(
smoothArgs = list(color = "black"),
predict = c("none", "lm", "ellipse"),
predictLevel = 0.95,
predictArgs = list(color = "black", linetype = 2, linewidth = 1, fill = NA),
predictArgs = .predictArgs(),
xBreaks = NULL,
yBreaks = NULL,
legendPosition = "none"
Expand Down Expand Up @@ -175,6 +175,26 @@ jaspBivariate <- function(
return(plot)
}

.predictArgs <- function(color = "black", linetype = 2, linewidth = 1, fill = NA, ...) {
args <- list(...)
args[["color"]] <- color
args[["linetype"]] <- linetype
args[["linewidth"]] <- linewidth
args[["fill"]] <- fill

return(args)
}

.smoothArgs <- function(method = "lm", se = FALSE, level = 0.95, formula = y~x, ...) {
args <- list(...)
args[["method"]] <- method
args[["se"]] <- se
args[["level"]] <- level
args[["formula"]] <- formula

return(args)
}

#' @title Bivariate plots with marginal distributions along the axes.
#'
#' @description This plot consists of four elements:
Expand Down
4 changes: 2 additions & 2 deletions man/jaspBivariate.Rd

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

0 comments on commit 25a4694

Please sign in to comment.