-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from boyiguo1/v1.3.1
V1.3.1
- Loading branch information
Showing
7 changed files
with
155 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#' @param bins numeric vector giving number of bins in both vertical and | ||
#' horizontal directions. Set to 30 by default. | ||
#' | ||
#' @rdname add_fill | ||
#' @export | ||
#' @importFrom ggplot2 stat_summary_hex scale_fill_gradient after_stat | ||
add_fill_bin <- function( | ||
p, | ||
var, | ||
bins = 30, | ||
point_size = 2.8, | ||
...){ | ||
p + | ||
stat_summary_hex( | ||
aes(z = !!sym(var), fill = after_stat(value)), | ||
color = "transparent", | ||
geom = "point", | ||
shape = 21, | ||
size = 2.8, | ||
fun = sum, | ||
bins = bins | ||
) + | ||
scale_fill_gradient(name = var) | ||
} | ||
|
||
utils::globalVariables("value") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#' @param bins numeric vector giving number of bins in both vertical and | ||
#' horizontal directions. Set to 30 by default. | ||
#' @param ... Reserved for future arguments. | ||
#' | ||
#' @rdname add_ground | ||
#' @export | ||
#' @importFrom ggplot2 scale_color_discrete | ||
add_ground_bin <- function( | ||
p, | ||
var, | ||
bins = 30, | ||
stroke = 1, | ||
point_size = 3 | ||
,...){ | ||
p + | ||
stat_summary_hex( | ||
aes( | ||
z = !!sym(var), | ||
group = -1, | ||
color = after_stat(value), | ||
fill = after_stat(rep(NA_integer_, length(value))) | ||
), | ||
geom = "point", | ||
shape = 21, | ||
size = point_size, | ||
stroke = stroke, | ||
# Majority Voting | ||
fun = function(x){ | ||
ll <- data.frame(table(x)) | ||
as.character(ll[which.max(ll$Freq),"x"]) | ||
}, | ||
bins = bins | ||
) + | ||
scale_color_discrete(name = var) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters