Skip to content

Commit

Permalink
rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
hneth committed Dec 28, 2023
1 parent 8e7b3e9 commit 85f7402
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
18 changes: 10 additions & 8 deletions R/cum_risk.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,20 @@ for (i in 0:t){ # each period i:

# C. Plot ps list as cum-risk barplot: ------

#' plot_cum_ps plots the results of cumulative risk computations.
#' plot_cum_bar plots the results of cumulative risk computations
#' as a bar plot (with percentages of risk event counts
#' for each period t as a horizontal bar).
#'
#' @param data The data to plot (as list of named probabilities).
#' @param N population size.
#'
#' @importFrom grDevices colorRampPalette

plot_cum_ps <- function(ps, N = 100){
plot_cum_bar <- function(data, N = 100){

# Plot dimensions:
x_max <- N
y_max <- length(ps) + 1
y_max <- length(data) + 1

# Initialize plotting area:
plot(0:1, 0:1, type = "n",
Expand All @@ -191,7 +193,7 @@ plot_cum_ps <- function(ps, N = 100){


# Initialize color palette:
n_cols <- 1 + length(ps)
n_cols <- 1 + length(data)
col_lo <- "grey96"
col_hi <- "firebrick" # "olivedrab" # grey20" # "red3"

Expand All @@ -200,11 +202,11 @@ plot_cum_ps <- function(ps, N = 100){
# unikn::seecol(pal)

# For each time/period/round:
for (t in 1:length(ps)){
for (t in 1:length(data)){

# print(t)

v <- ps[[t]] # get current vector
v <- data[[t]] # get current vector

# ToDo: Sort by vector values by value names.

Expand Down Expand Up @@ -239,10 +241,10 @@ plot_cum_ps <- function(ps, N = 100){

title(main = paste0("Cumulative risks (r = ", r, "; t = ", t, "; N = ", N, ")"))

} # plot_cum_ps().
} # plot_cum_bar().

# # Check:
# plot_cum_ps(ps, N = N)
# plot_cum_bar(data = ps, N = N)

# ?: +++ here now +++:

Expand Down
20 changes: 20 additions & 0 deletions man/plot_cum_bar.Rd

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

11 changes: 0 additions & 11 deletions man/plot_cum_ps.Rd

This file was deleted.

0 comments on commit 85f7402

Please sign in to comment.