Skip to content

Conversation

@jdblischak
Copy link
Contributor

I simplified the package by having the primary output object be a tibble. To obtain a summary value, you can call summary() or a specific function to calculate it.

library("dynamicpv")

cashflow <- c(110, 120, 130, 140, 150)
disc <- 0.03
pv1 <- dynpv(payoffs=cashflow, discrate=disc)

total(pv1)
## [1] 610.4352
mean(pv1)
## [1] 610.4352
uptake(pv1)
## [1] 1

summary(pv1)
## Summary of Dynamic Pricing and Uptake
##      Number of cohorts:             5 
##      Number of times:               1 
##      Total uptake:                  1 
##      Total present value:           610.4352 
##      Mean present value:            610.4352

str(pv1)
## dynpv [5 × 9] (S3: dynpv/tbl_df/tbl/data.frame)
##  $ j : int [1:5] 1 1 1 1 1
##  $ k : int [1:5] 1 2 3 4 5
##  $ l : num [1:5] 0 0 0 0 0
##  $ t : num [1:5] 1 2 3 4 5
##  $ uj: num [1:5] 1 1 1 1 1
##  $ pk: num [1:5] 110 120 130 140 150
##  $ R : num [1:5] 1 1 1 1 1
##  $ v : num [1:5] 1 0.971 0.943 0.915 0.888
##  $ pv: num [1:5] 110 117 123 128 133

str(summary(pv1))
## List of 6
##  $ ncoh      : int 5
##  $ ntimes    : int 1
##  $ uptake    : num 1
##  $ sum_by_coh: num 610
##  $ total     : num 610
##  $ mean      : num 610
##  - attr(*, "class")= chr "dynpv_summary"

I also cleaned up a few things to get a clean R CMD check

@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
R/dynamic.R 100.00% <100.00%> (ø)
R/extract.R 100.00% <100.00%> (ø)
R/future.R 100.00% <100.00%> (ø)
R/oop.R 98.70% <100.00%> (+8.27%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jdblischak
Copy link
Contributor Author

The failure with R-devel is unrelated to this PR. There was a failure installing {fastGHQuad} from source

@dom-muston dom-muston merged commit e2ae62b into MSDLLCpapers:main Dec 11, 2025
7 of 8 checks passed
@jdblischak jdblischak deleted the simplify branch December 12, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants