Skip to content

Commit

Permalink
Bug fixes; Update internal ggplot2 usage (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Nov 22, 2023
1 parent 9e7228c commit 8131749
Show file tree
Hide file tree
Showing 228 changed files with 10,739 additions and 10,614 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Description:
plot networks.
Depends:
R (>= 3.1),
ggplot2 (>= 3.3.4)
ggplot2 (>= 3.4.4)
Imports:
dplyr (>= 1.0.0),
tidyr (>= 1.3.0),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ import(RColorBrewer)
import(ggplot2)
import(utils)
importFrom(dplyr,"%>%")
importFrom(dplyr,all_of)
importFrom(dplyr,group_by)
importFrom(dplyr,rename)
importFrom(dplyr,summarise)
Expand Down
40 changes: 19 additions & 21 deletions R/deprecated.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ v1_ggmatrix_theme <- function() {
#' p_ <- GGally::print_if_interactive
#'
#' data(tips)
#' p_(ggally_cor_v1_5(tips, mapping = ggplot2::aes_string(x = "total_bill", y = "tip")))
#' p_(ggally_cor_v1_5(tips, mapping = ggplot2::aes(total_bill, tip)))
#'
#' # display with no grid
#' p_(ggally_cor_v1_5(
#' tips,
#' mapping = ggplot2::aes_string(x = "total_bill", y = "tip"),
#' mapping = ggplot2::aes(total_bill, tip),
#' displayGrid = FALSE
#' ))
#'
Expand All @@ -66,26 +66,24 @@ v1_ggmatrix_theme <- function() {
#' # split by a variable
#' p_(ggally_cor_v1_5(
#' tips,
#' mapping = ggplot2::aes_string(x = "total_bill", y = "tip", color = "sex"),
#' mapping = ggplot2::aes(total_bill, tip, color = sex),
#' size = 5
#' ))
ggally_cor_v1_5 <- function(
data,
mapping,
alignPercent = 0.6,
method = "pearson", use = "complete.obs",
corAlignPercent = NULL, corMethod = NULL, corUse = NULL,
displayGrid = TRUE,
...
) {

if (! is.null(corAlignPercent)) {
data,
mapping,
alignPercent = 0.6,
method = "pearson", use = "complete.obs",
corAlignPercent = NULL, corMethod = NULL, corUse = NULL,
displayGrid = TRUE,
...) {
if (!is.null(corAlignPercent)) {
stop("'corAlignPercent' is deprecated. Please use argument 'alignPercent'")
}
if (! is.null(corMethod)) {
if (!is.null(corMethod)) {
stop("'corMethod' is deprecated. Please use argument 'method'")
}
if (! is.null(corUse)) {
if (!is.null(corUse)) {
stop("'corUse' is deprecated. Please use argument 'use'")
}

Expand Down Expand Up @@ -181,22 +179,22 @@ ggally_cor_v1_5 <- function(
for (i in length(names(mapping)):1) {
# find the last value of the aes, such as cyl of as.factor(cyl)
tmp_map_val <- deparse(mapping[names(mapping)[i]][[1]])
if (tmp_map_val[length(tmp_map_val)] %in% colnames(data))
if (tmp_map_val[length(tmp_map_val)] %in% colnames(data)) {
mapping[[names(mapping)[i]]] <- NULL
}

if (length(names(mapping)) < 1) {
mapping <- NULL
break;
break
}
}
}
}

if (
!is.null(colorData) &&
!inherits(colorData, "AsIs")
!inherits(colorData, "AsIs")
) {

cord <- ddply(
data.frame(x = xData, y = yData, color = colorData),
"color",
Expand Down Expand Up @@ -248,7 +246,8 @@ ggally_cor_v1_5 <- function(
yPos <- seq(
from = 0.9,
to = 0.2,
length.out = nrow(cord) + 1)
length.out = nrow(cord) + 1
)
yPos <- yPos * diff(yrange) + min(yrange, na.rm = TRUE)
yPos <- yPos[-1]
# print(range(yVal))
Expand All @@ -269,7 +268,6 @@ ggally_cor_v1_5 <- function(
),
hjust = 1,
...

)
} else {
# calculate variable ranges so the gridlines line up
Expand Down
7 changes: 2 additions & 5 deletions R/find-combo.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#' @author Barret Schloerke
#' @keywords internal
plot_types <- function(data, columnsX, columnsY, allowDiag = TRUE) {


plotTypesX <- lapply(data[columnsX], plotting_data_type)
plotTypesY <- lapply(data[columnsY], plotting_data_type)

Expand All @@ -26,7 +24,7 @@ plot_types <- function(data, columnsX, columnsY, allowDiag = TRUE) {
posX <- integer(n)
posY <- integer(n)

#horizontal then vertical
# horizontal then vertical
for (yI in seq_len(lenY)) {
yColName <- columnNamesY[yI]
for (xI in seq_len(lenX)) {
Expand Down Expand Up @@ -78,7 +76,6 @@ plot_types <- function(data, columnsX, columnsY, allowDiag = TRUE) {
#' @author Barret Schloerke
#' @keywords internal
find_plot_type <- function(col1Name, col2Name, type1, type2, isAllNa, allowDiag) {

# diag calculations
if (col1Name == col2Name && allowDiag) {
if (type1 == "na") {
Expand All @@ -94,7 +91,7 @@ find_plot_type <- function(col1Name, col2Name, type1, type2, isAllNa, allowDiag)
return("na")
}

#cat(names(data)[col2Name],": ", type2,"\t",names(data)[col1Name],": ",type1,"\n")
# cat(names(data)[col2Name],": ", type2,"\t",names(data)[col1Name],": ",type1,"\n")
isCats <- c(type1, type2) %in% "discrete"
if (any(isCats)) {
if (all(isCats)) {
Expand Down
Loading

0 comments on commit 8131749

Please sign in to comment.