Skip to content

Commit

Permalink
robustify pairsplot smooth
Browse files Browse the repository at this point in the history
  • Loading branch information
wolski committed Aug 26, 2024
1 parent 73e40d5 commit 6e04309
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,15 @@ panel_cor <- function(x, y, digits = 2, ...)
#' pairs_smooth(tmp,main="small data", diag.panel=panel_hist)
#' pairs_smooth(tmp,log="xy",main="small data", legend=TRUE)
#' @seealso also \code{\link{pairs}}
pairs_smooth <- function(dataframe, legend = FALSE, ...) {
pairs_smooth <- function(data, legend = FALSE, ...) {
while (nrow(na.omit(data)) < 100) {
non_na_counts <- apply(data, 2, function(x) sum(!is.na(x)))
min_col <- which.min(non_na_counts)
data <- data[, -min_col, drop = FALSE]
}

pairs(
dataframe,
data,
upper.panel = function(x, y) {
graphics::smoothScatter(x, y, add = TRUE)
graphics::abline(
Expand Down
6 changes: 3 additions & 3 deletions man/pairs_smooth.Rd

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

0 comments on commit 6e04309

Please sign in to comment.