diff --git a/.Rbuildignore b/.Rbuildignore index dec0635..96539a6 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -6,10 +6,7 @@ ^CODE_OF_CONDUCT\.md$ ^app/ ^publish_shiny.R -^publish_cran.R ^_pkgdown\.yml$ ^docs$ ^pkgdown$ ^\.github$ -^data/prioritized_sample\.xlsx$ -^sample_data$ diff --git a/.github/workflows/rhub.yaml b/.github/workflows/rhub.yaml deleted file mode 100644 index 74ec7b0..0000000 --- a/.github/workflows/rhub.yaml +++ /dev/null @@ -1,95 +0,0 @@ -# R-hub's generic GitHub Actions workflow file. It's canonical location is at -# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml -# You can update this file to a newer version using the rhub2 package: -# -# rhub::rhub_setup() -# -# It is unlikely that you need to modify this file manually. - -name: R-hub -run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" - -on: - workflow_dispatch: - inputs: - config: - description: 'A comma separated list of R-hub platforms to use.' - type: string - default: 'linux,windows,macos' - name: - description: 'Run name. You can leave this empty now.' - type: string - id: - description: 'Unique ID. You can leave this empty now.' - type: string - -jobs: - - setup: - runs-on: ubuntu-latest - outputs: - containers: ${{ steps.rhub-setup.outputs.containers }} - platforms: ${{ steps.rhub-setup.outputs.platforms }} - - steps: - # NO NEED TO CHECKOUT HERE - - uses: r-hub/actions/setup@v1 - with: - config: ${{ github.event.inputs.config }} - id: rhub-setup - - linux-containers: - needs: setup - if: ${{ needs.setup.outputs.containers != '[]' }} - runs-on: ubuntu-latest - name: ${{ matrix.config.label }} - strategy: - fail-fast: false - matrix: - config: ${{ fromJson(needs.setup.outputs.containers) }} - container: - image: ${{ matrix.config.container }} - - steps: - - uses: r-hub/actions/checkout@v1 - - uses: r-hub/actions/platform-info@v1 - with: - token: ${{ secrets.RHUB_TOKEN }} - job-config: ${{ matrix.config.job-config }} - - uses: r-hub/actions/setup-deps@v1 - with: - token: ${{ secrets.RHUB_TOKEN }} - job-config: ${{ matrix.config.job-config }} - - uses: r-hub/actions/run-check@v1 - with: - token: ${{ secrets.RHUB_TOKEN }} - job-config: ${{ matrix.config.job-config }} - - other-platforms: - needs: setup - if: ${{ needs.setup.outputs.platforms != '[]' }} - runs-on: ${{ matrix.config.os }} - name: ${{ matrix.config.label }} - strategy: - fail-fast: false - matrix: - config: ${{ fromJson(needs.setup.outputs.platforms) }} - - steps: - - uses: r-hub/actions/checkout@v1 - - uses: r-hub/actions/setup-r@v1 - with: - job-config: ${{ matrix.config.job-config }} - token: ${{ secrets.RHUB_TOKEN }} - - uses: r-hub/actions/platform-info@v1 - with: - token: ${{ secrets.RHUB_TOKEN }} - job-config: ${{ matrix.config.job-config }} - - uses: r-hub/actions/setup-deps@v1 - with: - job-config: ${{ matrix.config.job-config }} - token: ${{ secrets.RHUB_TOKEN }} - - uses: r-hub/actions/run-check@v1 - with: - job-config: ${{ matrix.config.job-config }} - token: ${{ secrets.RHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index cb68314..457525e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,3 @@ .DS_Store .quarto docs -data/prioritized_sample.xlsx -sample_data -app/rsconnect diff --git a/DESCRIPTION b/DESCRIPTION index 82be8ca..6addb68 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,27 +13,30 @@ License: GPL (>= 3) Imports: dplyr, ggplot2, + magrittr, ompr, ompr.roi, - openxlsx2, + openxlsx, patchwork, + renv, + ROI, + ROI.plugin.symphony, shiny, + tidyr, viridisLite, + shinylive, + httpuv, + here, + cpp11, + ROI.plugin.alabama, assertthat, - readODS, - tibble + readODS Suggests: pak, usethis, styler, roxygen2, - devtools, - rhub, - here, - cpp11, - renv, - ROI, - ROI.plugin.symphony + devtools Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 diff --git a/NAMESPACE b/NAMESPACE index b7905eb..ff85798 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,4 +4,3 @@ S3method(plot,prioritized_groups_list) export(file_extension) export(grouping_plot) export(prioritized_grouping) -export(read_input) diff --git a/R/prioritized_grouping.R b/R/prioritized_grouping.R index cd96070..d3d0594 100644 --- a/R/prioritized_grouping.R +++ b/R/prioritized_grouping.R @@ -16,12 +16,9 @@ utils::globalVariables(c("group", "grp", "i", "j", "value")) #' @export #' #' @examples -#' # prioritized_grouping( -#' # data=read.csv(here::here("data/prioritized_sample.csv")), -#' # pre_grouped=read.csv(here::here("data/pre_grouped.csv"))) |> plot() -#' data.frame(id=paste0("id",1:100), -#' matrix(replicate(100,sample(c(1:5,rep(NA,15)),10)),ncol=10,byrow = TRUE)) |> -#' prioritized_grouping() +#' prioritized_grouping( +#' data=read.csv(here::here("data/prioritized_sample.csv")), +#' pre_grouped=read.csv(here::here("data/pre_grouped.csv"))) |> plot() prioritized_grouping <- function(data, cap_classes = NULL, @@ -194,7 +191,7 @@ prioritized_grouping <- class(out) <- c("prioritized_groups_list", class(out)) - invisible(out) + return(out) } #' Assessment performance overview @@ -206,7 +203,7 @@ prioritized_grouping <- #' #' @param data A "prioritized_groups_list" class list from #' 'prioritized_grouping()' -#' @param columns number of columns in plot. Default=4. +#' @param columns number of columns in plot #' @param overall logical to only print overall groups mean priority/cost #' @param viridis.option option value passed on to 'viridisLite::viridis'. #' Default="D". @@ -220,11 +217,8 @@ prioritized_grouping <- #' #read.csv(here::here("data/prioritized_sample.csv")) |> #' # prioritized_grouping(cap_classes = sample(4:12, 17, TRUE)) |> #' # grouping_plot() -#' data.frame(id=paste0("id",1:100), -#' matrix(replicate(100,sample(c(1:5,rep(NA,15)),10)),ncol=10,byrow = TRUE)) |> -#' prioritized_grouping() |> grouping_plot(overall=TRUE) grouping_plot <- function(data, - columns = 4, + columns = NULL, overall = FALSE, viridis.option="D", viridis.direction=-1) { @@ -292,19 +286,18 @@ grouping_plot <- function(data, #' Plot extension for easy groupings plot #' -#' @param x data of class 'prioritized_groups_list' +#' @param data data of class 'prioritized_groups_list' #' @param ... passed on to 'grouping_plot()' #' #' @return ggplot2 list object #' @export #' #' @examples -#' # read.csv(here::here("data/prioritized_sample.csv")) |> -#' # prioritized_grouping() |> -#' # plot(overall = TRUE, viridis.option="D",viridis.direction=-1) -#' -plot.prioritized_groups_list <- function(x, ...) { - grouping_plot(x, ...) +#' read.csv(here::here("data/prioritized_sample.csv")) |> +#' prioritized_grouping() |> +#' plot(overall = TRUE, viridis.option="D",viridis.direction=-1) +plot.prioritized_groups_list <- function(data, ...) { + grouping_plot(data, ...) } ## Helper function for Shiny @@ -324,39 +317,3 @@ file_extension <- function(filenames) { filenames, perl = TRUE ) } - - -#' Flexible file import based on extension -#' -#' @param file file name -#' @param consider.na character vector of strings to consider as NAs -#' -#' @return tibble -#' @export -#' -#' @examples -#' read_input("https://raw.githubusercontent.com/agdamsbo/cognitive.index.lookup/main/data/sample.csv") -read_input <- function(file, consider.na = c("NA", '""', "")) { - ext <- file_extension(file) - - tryCatch( - { - if (ext == "csv") { - df <- utils::read.csv(file = file, na = consider.na) - } else if (ext %in% c("xls", "xlsx")) { - df <- openxlsx2::read_xlsx(file = file, na.strings = consider.na) - } else if (ext == "ods") { - df <- readODS::read_ods(file = file) - } else { - stop("Input file format has to be on of: - '.csv', '.xls', '.xlsx', '.dta' or '.ods'") - } - }, - error = function(e) { - # return a safeError if a parsing error occurs - stop(shiny::safeError(e)) - } - ) - - df -} diff --git a/app/rsconnect/shinyapps.io/agdamsbo/prioritized-grouping.dcf b/app/rsconnect/shinyapps.io/agdamsbo/prioritized-grouping.dcf new file mode 100644 index 0000000..19f67c7 --- /dev/null +++ b/app/rsconnect/shinyapps.io/agdamsbo/prioritized-grouping.dcf @@ -0,0 +1,10 @@ +name: prioritized-grouping +title: +username: agdamsbo +account: agdamsbo +server: shinyapps.io +hostUrl: https://api.shinyapps.io/v1 +appId: 12977223 +bundleId: 9205937 +url: https://agdamsbo.shinyapps.io/prioritized-grouping/ +version: 1 diff --git a/app/server.R b/app/server.R index f9e63c8..7e6e6a3 100644 --- a/app/server.R +++ b/app/server.R @@ -22,9 +22,6 @@ utils::globalVariables(c("group", "grp", "i", "j", "value")) - - - @@ -200,7 +197,7 @@ prioritized_grouping <- class(out) <- c("prioritized_groups_list", class(out)) - invisible(out) + return(out) } @@ -222,15 +219,12 @@ prioritized_grouping <- - - - grouping_plot <- function(data, - columns = 4, + columns = NULL, overall = FALSE, viridis.option="D", viridis.direction=-1) { @@ -308,9 +302,8 @@ grouping_plot <- function(data, - -plot.prioritized_groups_list <- function(x, ...) { - grouping_plot(x, ...) +plot.prioritized_groups_list <- function(data, ...) { + grouping_plot(data, ...) } ## Helper function for Shiny @@ -332,42 +325,6 @@ file_extension <- function(filenames) { } - - - - - - - - - - -read_input <- function(file, consider.na = c("NA", '""', "")) { - ext <- file_extension(file) - - tryCatch( - { - if (ext == "csv") { - df <- utils::read.csv(file = file, na = consider.na) - } else if (ext %in% c("xls", "xlsx")) { - df <- openxlsx2::read_xlsx(file = file, na.strings = consider.na) - } else if (ext == "ods") { - df <- readODS::read_ods(file = file) - } else { - stop("Input file format has to be on of: - '.csv', '.xls', '.xlsx', '.dta' or '.ods'") - } - }, - error = function(e) { - # return a safeError if a parsing error occurs - stop(shiny::safeError(e)) - } - ) - - df -} - - ######## #### Current file: app/server_raw.R ######## @@ -384,7 +341,27 @@ server <- function(input, output, session) { req(input$file1) # Make laoding dependent of file name extension (file_ext()) - df <- read_input(input$file1$datapath) + ext <- file_extension(input$file1$datapath) + + tryCatch( + { + if (ext == "csv") { + df <- utils::read.csv(input$file1$datapath,na.strings = c("NA", '""',"")) + } else if (ext %in% c("xls", "xlsx")) { + df <- openxlsx::read.xlsx(input$file1$datapath,na.strings = c("NA", '""',"")) + } else if (ext == "ods") { + df <- readODS::read_ods(file = file) + } else { + stop("Input file format has to be on of: + '.csv', '.xls', '.xlsx' or '.ods'") + } + }, + error = function(e) { + # return a safeError if a parsing error occurs + stop(safeError(e)) + } + ) + return(df) }) @@ -393,7 +370,18 @@ server <- function(input, output, session) { # req(input$file2) # Make laoding dependent of file name extension (file_ext()) if (!is.null(input$file2$datapath)){ - df <- read_input(input$file2$datapath) + ext <- file_extension(input$file2$datapath) + + if (ext == "csv") { + df <- utils::read.csv(input$file2$datapath,na.strings = c("NA", '""',"")) + } else if (ext %in% c("xls", "xlsx")) { + df <- openxlsx::read.xlsx(input$file2$datapath,na.strings = c("NA", '""',"")) + } else if (ext == "ods") { + df <- readODS::read_ods(file = file) + } else { + stop("Input file format has to be on of: + '.csv', '.xls', '.xlsx' or '.ods'") + } return(df) } else { diff --git a/app/server_raw.R b/app/server_raw.R index e32eb03..7f7ca04 100644 --- a/app/server_raw.R +++ b/app/server_raw.R @@ -10,7 +10,27 @@ server <- function(input, output, session) { req(input$file1) # Make laoding dependent of file name extension (file_ext()) - df <- read_input(input$file1$datapath) + ext <- file_extension(input$file1$datapath) + + tryCatch( + { + if (ext == "csv") { + df <- utils::read.csv(input$file1$datapath,na.strings = c("NA", '""',"")) + } else if (ext %in% c("xls", "xlsx")) { + df <- openxlsx::read.xlsx(input$file1$datapath,na.strings = c("NA", '""',"")) + } else if (ext == "ods") { + df <- readODS::read_ods(file = file) + } else { + stop("Input file format has to be on of: + '.csv', '.xls', '.xlsx' or '.ods'") + } + }, + error = function(e) { + # return a safeError if a parsing error occurs + stop(safeError(e)) + } + ) + return(df) }) @@ -19,7 +39,18 @@ server <- function(input, output, session) { # req(input$file2) # Make laoding dependent of file name extension (file_ext()) if (!is.null(input$file2$datapath)){ - df <- read_input(input$file2$datapath) + ext <- file_extension(input$file2$datapath) + + if (ext == "csv") { + df <- utils::read.csv(input$file2$datapath,na.strings = c("NA", '""',"")) + } else if (ext %in% c("xls", "xlsx")) { + df <- openxlsx::read.xlsx(input$file2$datapath,na.strings = c("NA", '""',"")) + } else if (ext == "ods") { + df <- readODS::read_ods(file = file) + } else { + stop("Input file format has to be on of: + '.csv', '.xls', '.xlsx' or '.ods'") + } return(df) } else { diff --git a/data/pre_grouped.csv b/data/pre_grouped.csv new file mode 100644 index 0000000..6e39ef3 --- /dev/null +++ b/data/pre_grouped.csv @@ -0,0 +1,11 @@ +"ID","group" +"sub36",16 +"sub105",10 +"sub112",3 +"sub61",15 +"sub27",8 +"sub78",7 +"sub110",1 +"sub129",2 +"sub109",12 +"sub46",14 diff --git a/data/prioritized_sample.csv b/data/prioritized_sample.csv new file mode 100644 index 0000000..7e8138c --- /dev/null +++ b/data/prioritized_sample.csv @@ -0,0 +1,134 @@ +"ID","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q" +"sub1",,,3,,,,,5,,,1,4,,,,2, +"sub2",,,,3,,5,,,,,,1,,2,,,4 +"sub3",4,,,,2,,3,,,,,,,,,5,1 +"sub4",,,,,2,,5,4,,,,1,,3,,, +"sub5",,,,5,,,2,,4,,1,,,,,3, +"sub6",,4,,,,,,,2,,1,,5,3,,, +"sub7",3,,,,,4,,,,,1,,,,2,5, +"sub8",,,,,2,,4,,1,,3,,,,,5, +"sub9",,3,,,,,,,1,5,,,4,,,,2 +"sub10",,,,4,,,,,,3,,,5,,2,1, +"sub11",,5,,4,,,2,,1,,,,,3,,, +"sub12",,,2,5,,,,,,,,,3,4,,,1 +"sub13",,,,5,,,,,,,,1,,3,2,,4 +"sub14",,3,4,,,5,,,,,,,,,2,,1 +"sub15",4,,,,5,,,2,1,,,,,,,,3 +"sub16",5,,,2,4,,,,,,1,,,,3,, +"sub17",,4,,,3,1,5,,,,,,,2,,, +"sub18",,,,,1,2,,,3,5,,,,,,4, +"sub19",,,4,,,,3,,1,,2,,,,5,, +"sub20",,,2,,,,1,,,3,4,5,,,,, +"sub21",5,4,,,,2,,,,,1,,,,,,3 +"sub22",,,,,1,,3,2,,,5,,,,4,, +"sub23",1,,,,4,,,,,,,,3,,2,,5 +"sub24",,,5,,,,,,,,,1,4,2,,3, +"sub25",2,5,,,,3,,,,,,,,,,1,4 +"sub26",,2,,5,,,4,,,,,,,,3,,1 +"sub27",,,,,3,2,,,5,,,,,4,,1, +"sub28",,,5,,,,,4,,,1,,,2,,3, +"sub29",2,,,,,3,,,1,,5,4,,,,, +"sub30",,,,,,,1,,,4,,3,,,2,,5 +"sub31",,,3,,,,,,,5,,1,,4,,,2 +"sub32",3,,,,,,,,2,5,,1,,,4,, +"sub33",,2,,,4,,1,5,,,,,,3,,, +"sub34",,,3,1,,,,4,,,5,,,,,,2 +"sub35",1,4,,,,,,2,,,,,,,3,5, +"sub36",,5,,3,,4,1,2,,,,,,,,, +"sub37",,,4,,3,,,,,,,1,2,5,,, +"sub38",,,,4,,,,3,,,,2,,1,5,, +"sub39",5,,,,1,4,,2,,,,,,3,,, +"sub40",,,,,4,2,5,1,,,,,,,3,, +"sub41",,1,,,,3,,5,,,,4,2,,,, +"sub42",,,,,,3,,,,,,1,5,,2,,4 +"sub43",,,,,,,,,,,1,,3,,4,2,5 +"sub44",,4,,,,,,,,,2,,,5,3,,1 +"sub45",2,3,,,,,4,,1,,,,,,,,5 +"sub46",,3,,,4,,,,,5,1,,,,,,2 +"sub47",,2,1,,5,,,,,3,,4,,,,, +"sub48",,2,,,1,3,,,,,5,4,,,,, +"sub49",,,,1,,,,3,,,,2,,,,4,5 +"sub50",3,,,,,,,5,,1,,,4,,,2, +"sub51",,,1,3,4,,,,2,,,,,,,5, +"sub52",,,1,,,,,,,4,5,,,,2,3, +"sub53",,,,2,5,,,,,1,,3,,,,4, +"sub54",,,,3,,,,,4,,,1,,2,,5, +"sub55",,,2,,,,4,,,,,,1,3,5,, +"sub56",,,,,,,,,3,,1,5,4,2,,, +"sub57",,,4,,2,,1,,,,,3,,,,,5 +"sub58",,3,,,,,,,,,,4,,,1,5,2 +"sub59",,,,4,,,1,,3,,5,2,,,,, +"sub60",,,,,,,,2,,,,1,3,5,,4, +"sub61",,,1,,,3,,2,4,,,,,5,,, +"sub62",1,2,,,,,,5,,4,,,,,,3, +"sub63",,2,,,3,,4,,,,,,,5,,,1 +"sub64",,,5,,,1,2,,,,3,,,,,,4 +"sub65",1,,3,2,,,,,,4,,,5,,,, +"sub66",,,,,,,1,,,,,2,,4,5,,3 +"sub67",4,5,,,,,2,,1,,,,,3,,, +"sub68",3,,,2,5,,4,,,1,,,,,,, +"sub69",5,,1,,,,4,,,,,3,,,2,, +"sub70",,2,,,,5,1,,,,3,,4,,,, +"sub71",5,,,,4,2,,1,,,3,,,,,, +"sub72",5,,,4,1,,,,,,3,,,,,2, +"sub73",5,3,,,,,,,4,,,1,,,2,, +"sub74",,5,,2,,3,,,4,,,,,,,,1 +"sub75",,,,,,,,,4,1,,5,2,,,,3 +"sub76",,1,,,,,2,5,4,,,3,,,,, +"sub77",5,,,,,,3,,,,,,,1,2,,4 +"sub78",4,,,,,,1,3,,2,,,,,,5, +"sub79",,,,3,,,,,,,4,1,5,,2,, +"sub80",,2,,,5,4,,,,,,,,,1,3, +"sub81",,,4,,,,2,,1,,,3,,,,,5 +"sub82",5,,,,,,,2,4,,,3,,,,,1 +"sub83",,2,,,,,4,5,1,,,,,,3,, +"sub84",,,,3,1,,,,,,2,,4,,,5, +"sub85",,,,1,4,,,5,,,,,,,2,,3 +"sub86",,,3,,,,,5,1,,,2,4,,,, +"sub87",,,,,2,5,4,,,,,,1,,,3, +"sub88",,,,,,,,,,,,2,3,1,,4,5 +"sub89",,,5,2,,,4,,,,,,,1,,3, +"sub90",,5,,1,,,,,,4,,3,,2,,, +"sub91",5,,,,,3,,,4,,2,,,1,,, +"sub92",,,,,,4,,5,,,2,,,,1,3, +"sub93",,,,,1,,,,,4,2,,5,,,3, +"sub94",1,,,,,,2,,,,,,4,5,,,3 +"sub95",,,,,4,2,3,,,5,,1,,,,, +"sub96",,5,,2,,,1,,,,,3,,4,,, +"sub97",1,3,,,,,,4,2,,,,,,5,, +"sub98",,,5,,3,,,,,,1,,,2,4,, +"sub99",,,4,,,,,5,,,,,1,3,2,, +"sub100",,2,,,,4,5,,,3,,,1,,,, +"sub101",,3,,1,2,,,,,,4,,,,,,5 +"sub102",1,,,2,,5,,,,,,3,,,,4, +"sub103",,3,,,,,5,,1,,,,,2,,,4 +"sub104",,5,,4,,1,2,3,,,,,,,,, +"sub105",,,,2,5,,,3,4,,1,,,,,, +"sub106",,,,4,5,3,2,,,,,1,,,,, +"sub107",2,1,3,,,,,,5,,4,,,,,, +"sub108",,,4,,,,,,,1,,,5,,2,,3 +"sub109",,4,,,,,,2,1,,,5,,3,,, +"sub110",,,,,3,,,,1,,,,,4,5,,2 +"sub111",,,,,,3,,,4,1,,,,,,2,5 +"sub112",,1,,,,,,,2,5,,,3,,,4, +"sub113",,,3,,,,,,,,1,5,,4,2,, +"sub114",,,,,1,3,,,,,5,,4,,2,, +"sub115",,1,,,4,2,,,,,3,5,,,,, +"sub116",,2,4,,,3,,5,1,,,,,,,, +"sub117",,,,,,2,,,,4,,1,,5,,3, +"sub118",,4,5,,,1,,,3,,,,,2,,, +"sub119",5,,,3,,,1,,,4,,,2,,,, +"sub120",1,2,4,,,,,,,,,,5,,,,3 +"sub121",,2,,,,5,,,,,,1,3,,,,4 +"sub122",3,,1,5,,,,,,,,4,,2,,, +"sub123",,1,3,,,,4,5,,,,,,,,2, +"sub124",,,2,,,4,,,,3,,,,,5,,1 +"sub125",,,,2,,,,,,,4,1,,5,,,3 +"sub126",,,,2,5,,3,,4,,,,,,,1, +"sub127",4,,,,,1,2,,,,,,5,3,,, +"sub128",,,,,1,4,,,,,,3,,,,2,5 +"sub129",,,,3,1,2,,4,,,,5,,,,, +"sub130",4,,,,1,,,5,,3,2,,,,,, +"sub131",,,,,1,3,,,,5,2,,,,,,4 +"sub132",,,,,2,,5,,,,3,,1,,,,4 +"sub133",,4,,,,,,3,,,,,,1,,2,5 diff --git a/data/prioritized_sample.xlsx b/data/prioritized_sample.xlsx new file mode 100644 index 0000000..a98a996 Binary files /dev/null and b/data/prioritized_sample.xlsx differ diff --git a/man/grouping_plot.Rd b/man/grouping_plot.Rd index 4d88f9a..eb5a2c8 100644 --- a/man/grouping_plot.Rd +++ b/man/grouping_plot.Rd @@ -6,7 +6,7 @@ \usage{ grouping_plot( data, - columns = 4, + columns = NULL, overall = FALSE, viridis.option = "D", viridis.direction = -1 @@ -16,7 +16,7 @@ grouping_plot( \item{data}{A "prioritized_groups_list" class list from 'prioritized_grouping()'} -\item{columns}{number of columns in plot. Default=4.} +\item{columns}{number of columns in plot} \item{overall}{logical to only print overall groups mean priority/cost} @@ -39,7 +39,4 @@ in the group. #read.csv(here::here("data/prioritized_sample.csv")) |> # prioritized_grouping(cap_classes = sample(4:12, 17, TRUE)) |> # grouping_plot() -data.frame(id=paste0("id",1:100), -matrix(replicate(100,sample(c(1:5,rep(NA,15)),10)),ncol=10,byrow = TRUE)) |> -prioritized_grouping() |> grouping_plot(overall=TRUE) } diff --git a/man/plot.prioritized_groups_list.Rd b/man/plot.prioritized_groups_list.Rd index ebf5ace..5fb24d9 100644 --- a/man/plot.prioritized_groups_list.Rd +++ b/man/plot.prioritized_groups_list.Rd @@ -4,10 +4,10 @@ \alias{plot.prioritized_groups_list} \title{Plot extension for easy groupings plot} \usage{ -\method{plot}{prioritized_groups_list}(x, ...) +\method{plot}{prioritized_groups_list}(data, ...) } \arguments{ -\item{x}{data of class 'prioritized_groups_list'} +\item{data}{data of class 'prioritized_groups_list'} \item{...}{passed on to 'grouping_plot()'} } @@ -18,8 +18,7 @@ ggplot2 list object Plot extension for easy groupings plot } \examples{ -# read.csv(here::here("data/prioritized_sample.csv")) |> -# prioritized_grouping() |> -# plot(overall = TRUE, viridis.option="D",viridis.direction=-1) - +read.csv(here::here("data/prioritized_sample.csv")) |> + prioritized_grouping() |> + plot(overall = TRUE, viridis.option="D",viridis.direction=-1) } diff --git a/man/prioritized_grouping.Rd b/man/prioritized_grouping.Rd index b9d2780..85f0eb5 100644 --- a/man/prioritized_grouping.Rd +++ b/man/prioritized_grouping.Rd @@ -34,10 +34,7 @@ list of custom class 'prioritized_groups_list' Solve grouping based on priorities or costs. } \examples{ -# prioritized_grouping( -# data=read.csv(here::here("data/prioritized_sample.csv")), -# pre_grouped=read.csv(here::here("data/pre_grouped.csv"))) |> plot() -data.frame(id=paste0("id",1:100), -matrix(replicate(100,sample(c(1:5,rep(NA,15)),10)),ncol=10,byrow = TRUE)) |> -prioritized_grouping() +prioritized_grouping( +data=read.csv(here::here("data/prioritized_sample.csv")), +pre_grouped=read.csv(here::here("data/pre_grouped.csv"))) |> plot() } diff --git a/man/read_input.Rd b/man/read_input.Rd deleted file mode 100644 index 12eeaff..0000000 --- a/man/read_input.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/prioritized_grouping.R -\name{read_input} -\alias{read_input} -\title{Flexible file import based on extension} -\usage{ -read_input(file, consider.na = c("NA", "\\"\\"", "")) -} -\arguments{ -\item{file}{file name} - -\item{consider.na}{character vector of strings to consider as NAs} -} -\value{ -tibble -} -\description{ -Flexible file import based on extension -} -\examples{ -read_input("https://raw.githubusercontent.com/agdamsbo/cognitive.index.lookup/main/data/sample.csv") -} diff --git a/publish_cran.R b/publish_cran.R deleted file mode 100644 index 214a384..0000000 --- a/publish_cran.R +++ /dev/null @@ -1,36 +0,0 @@ -# Checks for publishing - -# Rhub v2 - -# rhub::rhub_setup() - -# rhub::rhub_doctor() - -rhub::rhub_check(platforms = c( - "linux", - "macos", - "macos-arm64", - "windows")) - -# rhub::rhub_setup(overwrite = TRUE) -# rhub::rhub_platforms() - -# SPELLING - dont use usethis::use_spell_check() - tests create notes on CRAN - not good -devtools::spell_check() -spelling::update_wordlist() - - -# Release on CRAN - confirm e-mail -devtools::release() - -# Use the following to publish latest release to GitHub -usethis::use_github_release() - - -## Testing -## -# ds <- data.frame(id=paste0("id",1:100),matrix(replicate(100,sample(c(1:5,rep(NA,15)),10)),ncol=10,byrow = TRUE)) -# -# ls <- ds|> prioritized_grouping(seed = 7) -# -# ls$export |> tibble::as.tibble() |> dplyr::right_join(ds,by = c("ID"="id")) |> View() diff --git a/renv.lock b/renv.lock index f2cdbe9..05e0832 100644 --- a/renv.lock +++ b/renv.lock @@ -76,6 +76,33 @@ ], "Hash": "42ce9ee4c1cf168869f4386d2cdeadd2" }, + "ROI.plugin.alabama": { + "Package": "ROI.plugin.alabama", + "Version": "1.0-2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "ROI", + "alabama", + "methods", + "stats", + "utils" + ], + "Hash": "097f1b625baf91f0d8999a1385054250" + }, + "ROI.plugin.symphony": { + "Package": "ROI.plugin.symphony", + "Version": "1.0-0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "ROI", + "Rsymphony", + "methods", + "slam" + ], + "Hash": "0d5d6f983334cf25a47eef4b293fb299" + }, "Rcpp": { "Package": "Rcpp", "Version": "1.0.13", @@ -87,6 +114,51 @@ ], "Hash": "f27411eb6d9c3dada5edd444b8416675" }, + "Rsymphony": { + "Package": "Rsymphony", + "Version": "0.1-33", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R" + ], + "Hash": "3f55239fe534fe91e739c77d99a4ffbf" + }, + "alabama": { + "Package": "alabama", + "Version": "2023.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "numDeriv" + ], + "Hash": "593db7eb170506e6b61ca0c803201924" + }, + "archive": { + "Package": "archive", + "Version": "1.1.9", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "cli", + "glue", + "rlang", + "tibble" + ], + "Hash": "d26b62e131d4a8b65aba4e9554a4bf74" + }, + "askpass": { + "Package": "askpass", + "Version": "1.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "sys" + ], + "Hash": "c39f4155b3ceb1a9a2799d700fbd4b6a" + }, "assertthat": { "Package": "assertthat", "Version": "0.2.1", @@ -117,6 +189,16 @@ ], "Hash": "543776ae6848fde2f48ff3816d0628bc" }, + "brio": { + "Package": "brio", + "Version": "1.1.5", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "c1ee497a6d999947c2c224ae46799b1a" + }, "bslib": { "Package": "bslib", "Version": "0.8.0", @@ -150,6 +232,19 @@ ], "Hash": "cd9a672193789068eb5a2aad65a0dedf" }, + "callr": { + "Package": "callr", + "Version": "3.7.6", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "R6", + "processx", + "utils" + ], + "Hash": "d7e13f49c19103ece9e58ad2d83a7354" + }, "cellranger": { "Package": "cellranger", "Version": "1.1.0", @@ -228,6 +323,16 @@ ], "Hash": "859d96e65ef198fd43e82b9628d593ef" }, + "curl": { + "Package": "curl", + "Version": "5.2.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "d91263322a58af798f6cf3b13fd56dde" + }, "data.table": { "Package": "data.table", "Version": "1.16.0", @@ -239,6 +344,19 @@ ], "Hash": "fb24e05d4a91d8b1c7ff8e284bde834a" }, + "desc": { + "Package": "desc", + "Version": "1.4.3", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "R6", + "cli", + "utils" + ], + "Hash": "99b79fcbd6c4d1ce087f5c5c758b384f" + }, "digest": { "Package": "digest", "Version": "0.6.37", @@ -299,6 +417,16 @@ "Repository": "RSPM", "Hash": "aa5e1cd11c2d15497494c5292d7ffcc8" }, + "filelock": { + "Package": "filelock", + "Version": "1.0.3", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R" + ], + "Hash": "192053c276525c8495ccfd523aa8f2d1" + }, "fontawesome": { "Package": "fontawesome", "Version": "0.5.2", @@ -358,6 +486,34 @@ ], "Hash": "44c6a2f8202d5b7e878ea274b1092426" }, + "gh": { + "Package": "gh", + "Version": "1.4.1", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "cli", + "gitcreds", + "glue", + "httr2", + "ini", + "jsonlite", + "lifecycle", + "rlang" + ], + "Hash": "fbbbc48eba7a6626a08bb365e44b563b" + }, + "gitcreds": { + "Package": "gitcreds", + "Version": "0.1.2", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R" + ], + "Hash": "ab08ac61f3e1be454ae21911eb8bc2fe" + }, "glue": { "Package": "glue", "Version": "1.8.0", @@ -384,6 +540,30 @@ ], "Hash": "e18861963cbc65a27736e02b3cd3c4a0" }, + "here": { + "Package": "here", + "Version": "1.0.1", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "rprojroot" + ], + "Hash": "24b224366f9c2e7534d2344d10d59211" + }, + "hms": { + "Package": "hms", + "Version": "1.1.3", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "lifecycle", + "methods", + "pkgconfig", + "rlang", + "vctrs" + ], + "Hash": "b59377caa7ed00fa41808342002138f9" + }, "htmltools": { "Package": "htmltools", "Version": "0.5.8.1", @@ -415,6 +595,34 @@ ], "Hash": "d55aa087c47a63ead0f6fc10f8fa1ee0" }, + "httr2": { + "Package": "httr2", + "Version": "1.0.5", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "R6", + "cli", + "curl", + "glue", + "lifecycle", + "magrittr", + "openssl", + "rappdirs", + "rlang", + "vctrs", + "withr" + ], + "Hash": "d84e4c33206aaace37714901ac2b00c3" + }, + "ini": { + "Package": "ini", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6154ec2223172bce8162d4153cda21f7" + }, "isoband": { "Package": "isoband", "Version": "0.2.7", @@ -517,6 +725,13 @@ ], "Hash": "4062982514dd797c7013124da49994c8" }, + "lpSolve": { + "Package": "lpSolve", + "Version": "5.6.21", + "Source": "Repository", + "Repository": "RSPM", + "Hash": "730a90bdc519fb0caff03df11218ddd8" + }, "magrittr": { "Package": "magrittr", "Version": "2.0.3", @@ -602,6 +817,16 @@ ], "Hash": "ccbb8846be320b627e6aa2b4616a2ded" }, + "numDeriv": { + "Package": "numDeriv", + "Version": "2016.8-1.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "df58958f293b166e4ab885ebcad90e02" + }, "ompr": { "Package": "ompr", "Version": "1.0.4", @@ -634,22 +859,32 @@ ], "Hash": "0f9f0bb7e9cff9da0237c8bd206d40a2" }, - "openxlsx2": { - "Package": "openxlsx2", - "Version": "1.9", + "openssl": { + "Package": "openssl", + "Version": "2.2.2", "Source": "Repository", - "Repository": "CRAN", + "Repository": "RSPM", + "Requirements": [ + "askpass" + ], + "Hash": "d413e0fef796c9401a4419485f709ca1" + }, + "openxlsx": { + "Package": "openxlsx", + "Version": "4.2.7.1", + "Source": "Repository", + "Repository": "RSPM", "Requirements": [ "R", - "R6", "Rcpp", "grDevices", - "magrittr", + "methods", + "stats", "stringi", "utils", "zip" ], - "Hash": "f3e00e7d16abb500e63faee67b7dc1a7" + "Hash": "14304e44a0f90fa2d0f905472333c561" }, "patchwork": { "Package": "patchwork", @@ -687,6 +922,40 @@ ], "Hash": "15da5a8412f317beeee6175fbc76f4bb" }, + "pkgbuild": { + "Package": "pkgbuild", + "Version": "1.4.4", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "R6", + "callr", + "cli", + "desc", + "processx" + ], + "Hash": "a29e8e134a460a01e0ca67a4763c595b" + }, + "pkgcache": { + "Package": "pkgcache", + "Version": "2.2.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "callr", + "cli", + "curl", + "filelock", + "jsonlite", + "processx", + "tools", + "utils" + ], + "Hash": "502554da4ec4d917b737e6b0fe14dd11" + }, "pkgconfig": { "Package": "pkgconfig", "Version": "2.0.3", @@ -697,6 +966,68 @@ ], "Hash": "01f28d4278f15c76cddbea05899c5d6f" }, + "pkgdepends": { + "Package": "pkgdepends", + "Version": "0.8.0", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "R6", + "callr", + "cli", + "curl", + "desc", + "filelock", + "jsonlite", + "lpSolve", + "pkgbuild", + "pkgcache", + "processx", + "ps", + "stats", + "utils", + "zip" + ], + "Hash": "eb7e3e965327555a527196d26d0643e4" + }, + "prettyunits": { + "Package": "prettyunits", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "6b01fc98b1e86c4f705ce9dcfd2f57c7" + }, + "processx": { + "Package": "processx", + "Version": "3.8.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "ps", + "utils" + ], + "Hash": "0c90a7d71988856bad2a2a45dd871bb9" + }, + "progress": { + "Package": "progress", + "Version": "1.2.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "crayon", + "hms", + "prettyunits" + ], + "Hash": "f4625e061cb2865f111b47ff163a5ca6" + }, "promises": { "Package": "promises", "Version": "1.3.0", @@ -713,6 +1044,32 @@ ], "Hash": "434cd5388a3979e74be5c219bcd6e77d" }, + "ps": { + "Package": "ps", + "Version": "1.8.0", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "utils" + ], + "Hash": "4b9c8485b0c7eecdf0a9ba5132a45576" + }, + "purrr": { + "Package": "purrr", + "Version": "1.0.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "lifecycle", + "magrittr", + "rlang", + "vctrs" + ], + "Hash": "1cba04a4e9414bdefc9dcaa99649a8dc" + }, "rappdirs": { "Package": "rappdirs", "Version": "0.3.3", @@ -779,6 +1136,16 @@ ], "Hash": "3eec01f8b1dee337674b2e34ab1f9bc1" }, + "rprojroot": { + "Package": "rprojroot", + "Version": "2.0.4", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R" + ], + "Hash": "4c8415e0ec1e29f3f4f6fc108bef0144" + }, "sass": { "Package": "sass", "Version": "0.4.9", @@ -846,6 +1213,31 @@ ], "Hash": "6a293995a66e12c48d13aa1f957d09c7" }, + "shinylive": { + "Package": "shinylive", + "Version": "0.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "archive", + "brio", + "cli", + "fs", + "gh", + "glue", + "httr2", + "jsonlite", + "pkgdepends", + "progress", + "rappdirs", + "renv", + "rlang", + "tools", + "whisker", + "withr" + ], + "Hash": "224c8c0502bb0ead1fd1b4b32ea04a90" + }, "slam": { "Package": "slam", "Version": "0.1-53", @@ -880,6 +1272,30 @@ ], "Hash": "39e1144fd75428983dc3f63aa53dfa91" }, + "stringr": { + "Package": "stringr", + "Version": "1.5.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "glue", + "lifecycle", + "magrittr", + "rlang", + "stringi", + "vctrs" + ], + "Hash": "960e2ae9e09656611e0b8214ad543207" + }, + "sys": { + "Package": "sys", + "Version": "3.4.3", + "Source": "Repository", + "Repository": "RSPM", + "Hash": "de342ebfebdbf40477d0758d05426646" + }, "tibble": { "Package": "tibble", "Version": "3.2.1", @@ -899,6 +1315,29 @@ ], "Hash": "a84e2cc86d07289b3b6f5069df7a004c" }, + "tidyr": { + "Package": "tidyr", + "Version": "1.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "cpp11", + "dplyr", + "glue", + "lifecycle", + "magrittr", + "purrr", + "rlang", + "stringr", + "tibble", + "tidyselect", + "utils", + "vctrs" + ], + "Hash": "915fb7ce036c22a6a33b5a8adb712eb1" + }, "tidyselect": { "Package": "tidyselect", "Version": "1.2.1", @@ -960,6 +1399,13 @@ ], "Hash": "c826c7c4241b6fc89ff55aaea3fa7491" }, + "whisker": { + "Package": "whisker", + "Version": "0.4.1", + "Source": "Repository", + "Repository": "RSPM", + "Hash": "c6abfa47a46d281a7d5159d0a8891e88" + }, "withr": { "Package": "withr", "Version": "3.0.1",