
Save User Proposal
save_proposal.Rd
This function stores proposals generated by the build_proposal()
function in R's internal data directory. It is useful when users want to reuse a proposal across multiple R sessions.
Arguments
- proposal
list representing an optimized proposal generated using the
build_proposal()
function.- proposal_name
string specifying the name under which the proposal will be saved.
Value
This function will produce an error if the proposal is not generated by the build_proposal()
function. Otherwise, it successfully saves the proposal without returning any value upon completion.
Examples
# First, let's create a proposal to sample from a standard normal distribution
f_normal <- function(x) { 0.3989423 * exp( -0.5 * x^2) }
normal_proposal = build_proposal(f = f_normal, modes = 0, lower = -Inf, upper = Inf, steps = 1000)
print(normal_proposal)
#>
#> ── Proposal Summary ────────────────────────────────────────────────────────────
#> • Total steps: 1,000
#> • Steps range: [-2.876766, 2.876766]
#> • Sampling efficiency: 99.56%
# Then, we can save this proposal in R's internal data directory using `save_proposal()`
# with the name "normal"
save_proposal(normal_proposal, "normal")
# To make sure the `normal_proposal` has been stored in R's internal data directory,
# we can print all saved proposals using `print_proposals()`
print_proposals()
#>
#> ── Proposals Data ──────────────────────────────────────────────────────────────
#> Name | Size (KB) | Date
#> -----------------------------------------------
#> bimodal | 26.88 | 2025-03-10 14:27:27
#> normal | 23.05 | 2025-03-10 14:27:27
#> -----------------------------------------------
#> Total Size: 49.93