Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

87 rewrite pkg structure #92

Merged
merged 14 commits into from
Apr 17, 2024
18 changes: 10 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,25 @@ Depends:
R (>= 4.1.0),
shiny (>= 1.7.0)
Imports:
lpSolveAPI (>= 5.5.2),
bslib (>= 0.5.1),
cli (>= 3.6.0),
ggplot2 (>= 3.3.0),
haven (>= 2.5.0),
htmltools,
lpSolveAPI (>= 5.5.2),
markdown,
productivity (>= 1.1.0),
readxl,
writexl,
bslib (>= 0.5.1),
ggplot2 (>= 3.3.0),
reactable (>= 0.4.0),
cli (>= 3.6.0)
readxl,
rlang (>= 1.1.0),
scales,
writexl
Suggests:
Benchmarking (>= 0.30),
data.table,
rmarkdown,
knitr,
scales,
rlang,
magick,
testthat (>= 3.0.0),
tibble,
withr
Expand Down
12 changes: 12 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,15 @@ import(reactable)
import(readxl)
import(shiny)
import(writexl)
importFrom(grDevices,chull)
importFrom(grDevices,nclass.FD)
importFrom(grDevices,nclass.Sturges)
importFrom(productivity,malm)
importFrom(rlang,list2)
importFrom(scales,label_number)
importFrom(stats,complete.cases)
importFrom(stats,median)
importFrom(stats,quantile)
importFrom(stats,rnorm)
importFrom(stats,sd)
importFrom(stats,var)
ohjakobsen marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Updated documentation for `run_pioneer()`
- Added custom functions for DEA calculations in order to remove `{Benchmarking}` as a dependency (#80)
- All R functions - including `server()` and `ui()` - have now been moved to the `R` directory with benefits to how internal functions are accessed. In additions, the global environment should be untouched when the app is run (#87)

## Bug fixes

Expand Down
15 changes: 9 additions & 6 deletions inst/app/R/fct_dea-bootstrap.R → R/fct_dea-bootstrap.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#' @importFrom stats complete.cases median quantile rnorm sd var
ohjakobsen marked this conversation as resolved.
Show resolved Hide resolved
NULL

bw_rule <- function(delta, rule = 'ucv') {
ohjakobsen marked this conversation as resolved.
Show resolved Hide resolved
# Values must be in range 1, Inf. Take inverse if values are in range 0, 1
if (min(delta) < 1) {
Expand All @@ -8,10 +11,10 @@ bw_rule <- function(delta, rule = 'ucv') {
delta_2m <- c(delta_m, 2 - delta_m)
# See Daraio & Wilson (2007) for a discussion on methods for determining bandwidth
h <- switch(rule,
silverman = bw.nrd0(delta_2m),
scott = bw.nrd(delta_2m),
ucv = suppressWarnings({ h <- bw.ucv(delta_2m) }),
suppressWarnings({ h <- bw.ucv(delta_2m) })
silverman = stats::bw.nrd0(delta_2m),
scott = stats::bw.nrd(delta_2m),
ucv = suppressWarnings({ h <- stats::bw.ucv(delta_2m) }),
suppressWarnings({ h <- stats::bw.ucv(delta_2m) })
)
# See Daraio & Wilson (2007), p. 61, eq. 3.26
h <- h * 2^(1/5) * (length(delta_m)/length(delta))^(1/5) * (sd(delta)/sd(delta_2m))
Expand All @@ -38,11 +41,11 @@ perform_boot <- function(x, y, rts, orientation, i, h, theta, boot) {
beta <- bootstrap_sample(theta, h = h)
if (orientation == 'in') {
x_ref <- (theta / beta) * x
boot[, i] <- pioneeR:::compute_efficiency(x, y, rts = rts, orientation = orientation, xref = x_ref, yref = y, values_only = TRUE)$values
boot[, i] <- compute_efficiency(x, y, rts = rts, orientation = orientation, xref = x_ref, yref = y, values_only = TRUE)$values
} else if (orientation == 'out') {
beta <- 1 / beta
y_ref <- (theta / beta) * y
boot[, i] <- pioneeR:::compute_efficiency(x, y, rts = rts, orientation = orientation, xref = x, yref = y_ref, values_only = TRUE)$values
boot[, i] <- compute_efficiency(x, y, rts = rts, orientation = orientation, xref = x, yref = y_ref, values_only = TRUE)$values
}
return(invisible(boot))
}
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions inst/app/R/mod_file-upload.R → R/mod_file-upload.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
library(reactable)

file_upload_ui <- function(id, wrap = FALSE, ...) {
ns <- NS(id)
ohjakobsen marked this conversation as resolved.
Show resolved Hide resolved
if (wrap) {
Expand Down Expand Up @@ -76,7 +74,7 @@ file_upload_srv <- function(id) {
if (ext %in% c('csv', 'tsv', 'dsv', 'txt')) {
req(input$file_sep, input$file_dec)
header <- if (is.null(input$file_header)) TRUE else as.logical(input$file_header)
clean_doc <- read.table(
clean_doc <- utils::read.table(
textConnection(raw_file()),
sep = input$file_sep,
dec = input$file_dec,
Expand Down
Loading
Loading