Skip to content

Commit 2d5c8a2

Browse files
committed
properly setup function with methods for different data types
1 parent 9ce1f9b commit 2d5c8a2

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-6
lines changed

NAMESPACE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method(GenTimeTrend,default)
4+
S3method(GenTimeTrend,numeric)
35
export("%<>%")
46
export("%>%")
57
export(eviatlas)
6-
export(save_shiny_app)
8+
export(save_eviatlas_app)
79
export(shiny_config)
810
export(shiny_server)
911
export(shiny_ui)

R/GenTimeTrend.R

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
#' @keywords internal
66

77
GenTimeTrend <- function(idata, hist_col, axis_txt_lim = 60) {
8-
# bind variables locally to function
9-
idata <- hist_col <- axis_txt_lim <- NULL
10-
118
UseMethod("GenTimeTrend", object = idata[hist_col][[1]])
129
}
1310

11+
#' Create Histogram from dataset - default method
12+
#' @method GenTimeTrend default
13+
#' @export
14+
#' @keywords internal
1415
GenTimeTrend.default <- function(idata, hist_col, axis_txt_lim = 60) {
1516
gttmp <- ggplot2::ggplot(idata, ggplot2::aes_string(x = hist_col)) +
1617
ggplot2::geom_bar(
@@ -19,7 +20,10 @@ GenTimeTrend.default <- function(idata, hist_col, axis_txt_lim = 60) {
1920
fill = "dodger blue"
2021
) +
2122
ggplot2::labs(y = "Studies") +
22-
ggplot2::scale_x_discrete(name = paste(hist_col), labels = function(x) substr(x, 1, axis_txt_lim)) +
23+
ggplot2::scale_x_discrete(
24+
name = paste(hist_col),
25+
labels = function(x) substr(x, 1, axis_txt_lim)
26+
) +
2327
ggplot2::theme_bw() +
2428
ggplot2::theme(
2529
axis.line = ggplot2::element_line(colour = "black"),
@@ -31,12 +35,21 @@ GenTimeTrend.default <- function(idata, hist_col, axis_txt_lim = 60) {
3135
# Rotate xaxis label if too many categories
3236
if (dplyr::n_distinct(idata[hist_col]) > 15) {
3337
gttmp <- gttmp + ggplot2::theme(
34-
axis.text.x = ggplot2::element_text(angle = 40, hjust = 0.95, size = 12)
38+
axis.text.x = ggplot2::element_text(
39+
angle = 40,
40+
hjust = 0.95,
41+
size = 12
42+
)
3543
)
3644
}
3745
gttmp
3846
}
3947

48+
#' Create Histogram from dataset - numeric column
49+
#' @method GenTimeTrend numeric
50+
#' @export
51+
#' @keywords internal
52+
4053
GenTimeTrend.numeric <- function(idata, hist_col, axis_txt_lim = 60) {
4154
ggplot2::ggplot(idata, ggplot2::aes_string(x = hist_col)) +
4255
ggplot2::geom_bar(

man/GenTimeTrend.default.Rd

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/GenTimeTrend.numeric.Rd

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)