Skip to content

Commit

Permalink
Merge branch 'master' into dev/update_vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
dgkf committed Dec 20, 2019
2 parents 51962ee + 2bc0d0b commit 29c3846
Show file tree
Hide file tree
Showing 15 changed files with 148 additions and 9 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Imports:
covr,
rvest,
memoise,
janitor
janitor,
cranlogs
RoxygenNote: 7.0.2
Suggests:
knitr,
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ S3method(as_pkg_ref,default)
S3method(as_pkg_ref,pkg_ref)
S3method(as_tibble,list_of_pkg_ref)
S3method(as_tibble,pkg_ref)
S3method(assess_downloads_1yr,pkg_ref)
S3method(assess_export_help,pkg_install)
S3method(assess_has_news,pkg_ref)
S3method(assess_license,pkg_ref)
Expand All @@ -29,6 +30,7 @@ S3method(pillar_shaft,pkg_metric_error)
S3method(print,dev_hint)
S3method(print,pkg_ref)
S3method(score,default)
S3method(score,pkg_metric_downloads_1yr)
S3method(score,pkg_metric_error)
S3method(score,pkg_metric_export_help)
S3method(score,pkg_metric_has_news)
Expand All @@ -43,6 +45,7 @@ export(.risk_weights)
export(all_assessments)
export(as_pkg_ref)
export(assess)
export(assess_downloads_1yr)
export(assess_export_help)
export(assess_has_news)
export(assess_license)
Expand All @@ -60,6 +63,7 @@ export(score_error_NA)
export(score_error_default)
export(score_error_zero)
export(summarize_risk)
import(cranlogs)
import(dplyr)
import(janitor)
import(memoise)
Expand Down
48 changes: 48 additions & 0 deletions R/assess_downloads.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#' Assess a package for the number of downloads in the past year
#'
#' @details The more times a package has been downloaded the more extensive the user testing and the greater chance there is of someone finding a bug and logging it.
#'
#' @eval assess_family_roxygen(
#' "downloads_1yr",
#' "a numeric value between [0,1] indicating the volume of downloads")
#'
#' @export
assess_downloads_1yr <- function(x, ...){
UseMethod("assess_downloads_1yr")
}
# assign a friendly name for assess column
attr(assess_downloads_1yr,"column_name") <- "downloads_1yr"
attr(assess_downloads_1yr,"label") <- "number of downloads in the past year"

pkg_ref_cache.downloads <- function(x, ...) {
cran_downloads(x$name, from=Sys.Date()-365, to=Sys.Date())
}

#' @import cranlogs
#' @export
assess_downloads_1yr.pkg_ref <- function(x, ...) {
downloads_1yr <- sum(x$downloads$count)
pkg_metric(downloads_1yr, class = "pkg_metric_downloads_1yr")
}

# Defining an Assessment Scoring Function
#' Score a package for the number of downloads in the past year
#'
#' Convert the number of downloads \code{x} in the past year into a validation score [0,1]
#' \deqn{ 1 - 150,000 / (x + 150,000) }
#'
#' @details The scoring function is a simplification of the classic logistic curve
#' \deqn{ 1 / (1 + exp(-k(x-x[0])) }
#' with a log scale for the number of downloads \eqn{x = log(x)},
#' sigmoid midpoint is 1000 downloads, ie. \eqn{x[0] = log(1,000)},
#' and logistic growth rate of \eqn{k = 0.5}.
# #' \deqn{ 1 - 1 / (1 + exp(log(x)-log(1.5e5))) = 1 - 150,000 / (x + 150,000) }
#'
#' @eval score_family_roxygen("downloads_1yr")
#' @return numeric value between \code{0} (low) and \code{1} (high download volume) converting the number of downloads.
#'
#' @export
score.pkg_metric_downloads_1yr <- function(x, ...) {
# simplification from logistic: 1 - 1 / (1 + exp(log(x)-log(1.5e5)))
1 - 1.5e5 / (x + 1.5e5)
}
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,25 @@ exploring the heterogeneity of code quality, and begin a broader conversation
about the validation of R packages. Primarily, this effort aims to provide some
context for validation within regulated industries.

## Quick Start
We sperate three steps in the workflow to assess the risk of an R package using `riskmetric`:

### Installation
1. **Finding a source for package information (installed package or CRAN/git source)** `pkg_ref()`
1. **Assessing the package under validation criteria** `assess()`
1. **Scoring assessment criteria** `score()`
1. **Summarize scores into an aggregate risk metric** `summarize_risk()`

The results will be a datasets of validation criteria and its overall risk score for each package as
showin in the example below.

## Installation

`riskmetric` is not yet on CRAN. Until it is, install using `devtools`.

```r
devtools::install_github("pharmaR/riskmetric")
```

### Example
## Example

Scrape metadata locally or remotely, then assess that metadata and score it to
estimate risk. For each package, derive a composite measure of risk, or a
Expand All @@ -49,10 +57,11 @@ pkg_ref(c("riskmetric", "utils", "tools")) %>%

## Get Involved

We had a bi-weekly sprint meeting for developer to discuss the progress.
We had a bi-weekly sprint meeting for developer to discuss the progress.

* Frequecy: every two weeks
* Starting Time: 2019/11/06 12:00 PM - 12:30 PM
* Contact `[email protected]` to add into the meeting invitation.
* Date: 1st and 3rd Wednesday of the month.
* Meeting Time: 12:00PM - 12:30PM EST
* [Project Planning Meeting Structure](https://github.com/pharmaR/riskmetric/issues/57)
* [Milestone](https://github.com/pharmaR/riskmetric/milestones)
* [Meeting Room](https://merck.webex.com/join/zhanyilo)
Expand Down
33 changes: 33 additions & 0 deletions man/assess_downloads_1yr.Rd

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

1 change: 1 addition & 0 deletions man/assess_export_help.Rd

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

1 change: 1 addition & 0 deletions man/assess_has_news.Rd

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

1 change: 1 addition & 0 deletions man/assess_news_current.Rd

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

2 changes: 1 addition & 1 deletion man/pkg_ref_cache.description.Rd

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

2 changes: 1 addition & 1 deletion man/pkg_ref_cache.news_urls.Rd

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

1 change: 1 addition & 0 deletions man/score.Rd

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

37 changes: 37 additions & 0 deletions man/score.pkg_metric_downloads_1yr.Rd

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

1 change: 1 addition & 0 deletions man/score.pkg_metric_export_help.Rd

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

1 change: 1 addition & 0 deletions man/score.pkg_metric_has_news.Rd

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

1 change: 1 addition & 0 deletions man/score.pkg_metric_news_current.Rd

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

0 comments on commit 29c3846

Please sign in to comment.