plot_feature_persistence {oppr} | R Documentation |
Plot a bar plot to visualize a project prioritization
Description
Create a bar plot to visualize how likely features are to persist into
the future under a solution to a project prioritization problem()
.
Usage
plot_feature_persistence(
x,
solution,
n = 1,
symbol_hjust = 0.007,
return_data = FALSE
)
Arguments
x |
project prioritization |
solution |
|
n |
|
symbol_hjust |
|
return_data |
|
Details
In this plot, each bar corresponds to a different feature. The length of each bar indicates the probability that a given feature will persist into the future, and the color of each bar indicates the weight for a given feature. Features that directly benefit from at least a single completely funded project with a non-zero cost are depicted with an asterisk symbol. Additionally, features that indirectly benefit from funded projects—because they are associated with partially funded projects that have non-zero costs and share actions with at least one completely funded project—are depicted with an open circle symbol.
Value
A ggplot()
object, or a
tibble::tbl_df()
object if return_data
is
TRUE
.
Examples
# set seed for reproducibility
set.seed(500)
# load the ggplot2 R package to customize plots
library(ggplot2)
# load data
data(sim_projects, sim_features, sim_actions)
# build problem
p <- problem(sim_projects, sim_actions, sim_features,
"name", "success", "name", "cost", "name") %>%
add_max_richness_objective(budget = 400) %>%
add_feature_weights("weight") %>%
add_binary_decisions() %>%
add_heuristic_solver(n = 10)
## Not run:
# solve problem
s <- solve(p)
# plot the first solution
plot(p, s)
# plot the second solution
plot(p, s, n = 2)
# since this function returns a ggplot2 plot object, we can customize the
# appearance of the plot using standard ggplot2 commands!
# for example, we can add a title
plot(p, s) + ggtitle("solution")
# we can also obtain the raw plotting data using return_data=TRUE
plot_data <- plot(p, s, return_data = TRUE)
print(plot_data)
## End(Not run)