diff --git a/.Rbuildignore b/.Rbuildignore index 96539a6..dec0635 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -6,7 +6,10 @@ ^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 new file mode 100644 index 0000000..74ec7b0 --- /dev/null +++ b/.github/workflows/rhub.yaml @@ -0,0 +1,95 @@ +# 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 457525e..cb68314 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ .DS_Store .quarto docs +data/prioritized_sample.xlsx +sample_data +app/rsconnect diff --git a/DESCRIPTION b/DESCRIPTION index 6addb68..82be8ca 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,30 +13,27 @@ License: GPL (>= 3) Imports: dplyr, ggplot2, - magrittr, ompr, ompr.roi, - openxlsx, + openxlsx2, patchwork, - renv, - ROI, - ROI.plugin.symphony, shiny, - tidyr, viridisLite, - shinylive, - httpuv, - here, - cpp11, - ROI.plugin.alabama, assertthat, - readODS + readODS, + tibble Suggests: pak, usethis, styler, roxygen2, - devtools + devtools, + rhub, + here, + cpp11, + renv, + ROI, + ROI.plugin.symphony Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 diff --git a/NAMESPACE b/NAMESPACE index ff85798..b7905eb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,3 +4,4 @@ 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 d3d0594..cd96070 100644 --- a/R/prioritized_grouping.R +++ b/R/prioritized_grouping.R @@ -16,9 +16,12 @@ 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() +#' # 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 <- function(data, cap_classes = NULL, @@ -191,7 +194,7 @@ prioritized_grouping <- class(out) <- c("prioritized_groups_list", class(out)) - return(out) + invisible(out) } #' Assessment performance overview @@ -203,7 +206,7 @@ prioritized_grouping <- #' #' @param data A "prioritized_groups_list" class list from #' 'prioritized_grouping()' -#' @param columns number of columns in plot +#' @param columns number of columns in plot. Default=4. #' @param overall logical to only print overall groups mean priority/cost #' @param viridis.option option value passed on to 'viridisLite::viridis'. #' Default="D". @@ -217,8 +220,11 @@ 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 = NULL, + columns = 4, overall = FALSE, viridis.option="D", viridis.direction=-1) { @@ -286,18 +292,19 @@ grouping_plot <- function(data, #' Plot extension for easy groupings plot #' -#' @param data data of class 'prioritized_groups_list' +#' @param x 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(data, ...) { - grouping_plot(data, ...) +#' # 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, ...) } ## Helper function for Shiny @@ -317,3 +324,39 @@ 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 deleted file mode 100644 index 19f67c7..0000000 --- a/app/rsconnect/shinyapps.io/agdamsbo/prioritized-grouping.dcf +++ /dev/null @@ -1,10 +0,0 @@ -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 7e6e6a3..f9e63c8 100644 --- a/app/server.R +++ b/app/server.R @@ -22,6 +22,9 @@ utils::globalVariables(c("group", "grp", "i", "j", "value")) + + + @@ -197,7 +200,7 @@ prioritized_grouping <- class(out) <- c("prioritized_groups_list", class(out)) - return(out) + invisible(out) } @@ -219,12 +222,15 @@ prioritized_grouping <- + + + grouping_plot <- function(data, - columns = NULL, + columns = 4, overall = FALSE, viridis.option="D", viridis.direction=-1) { @@ -302,8 +308,9 @@ grouping_plot <- function(data, -plot.prioritized_groups_list <- function(data, ...) { - grouping_plot(data, ...) + +plot.prioritized_groups_list <- function(x, ...) { + grouping_plot(x, ...) } ## Helper function for Shiny @@ -325,6 +332,42 @@ 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 ######## @@ -341,27 +384,7 @@ server <- function(input, output, session) { req(input$file1) # Make laoding dependent of file name extension (file_ext()) - 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)) - } - ) - + df <- read_input(input$file1$datapath) return(df) }) @@ -370,18 +393,7 @@ server <- function(input, output, session) { # req(input$file2) # Make laoding dependent of file name extension (file_ext()) if (!is.null(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'") - } + df <- read_input(input$file2$datapath) return(df) } else { diff --git a/app/server_raw.R b/app/server_raw.R index 7f7ca04..e32eb03 100644 --- a/app/server_raw.R +++ b/app/server_raw.R @@ -10,27 +10,7 @@ server <- function(input, output, session) { req(input$file1) # Make laoding dependent of file name extension (file_ext()) - 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)) - } - ) - + df <- read_input(input$file1$datapath) return(df) }) @@ -39,18 +19,7 @@ server <- function(input, output, session) { # req(input$file2) # Make laoding dependent of file name extension (file_ext()) if (!is.null(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'") - } + df <- read_input(input$file2$datapath) return(df) } else { diff --git a/data/pre_grouped.csv b/data/pre_grouped.csv deleted file mode 100644 index 6e39ef3..0000000 --- a/data/pre_grouped.csv +++ /dev/null @@ -1,11 +0,0 @@ -"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 deleted file mode 100644 index 7e8138c..0000000 --- a/data/prioritized_sample.csv +++ /dev/null @@ -1,134 +0,0 @@ -"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 deleted file mode 100644 index a98a996..0000000 Binary files a/data/prioritized_sample.xlsx and /dev/null differ diff --git a/man/grouping_plot.Rd b/man/grouping_plot.Rd index eb5a2c8..4d88f9a 100644 --- a/man/grouping_plot.Rd +++ b/man/grouping_plot.Rd @@ -6,7 +6,7 @@ \usage{ grouping_plot( data, - columns = NULL, + columns = 4, 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} +\item{columns}{number of columns in plot. Default=4.} \item{overall}{logical to only print overall groups mean priority/cost} @@ -39,4 +39,7 @@ 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 5fb24d9..ebf5ace 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}(data, ...) +\method{plot}{prioritized_groups_list}(x, ...) } \arguments{ -\item{data}{data of class 'prioritized_groups_list'} +\item{x}{data of class 'prioritized_groups_list'} \item{...}{passed on to 'grouping_plot()'} } @@ -18,7 +18,8 @@ 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 85f0eb5..b9d2780 100644 --- a/man/prioritized_grouping.Rd +++ b/man/prioritized_grouping.Rd @@ -34,7 +34,10 @@ 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() +# 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() } diff --git a/man/read_input.Rd b/man/read_input.Rd new file mode 100644 index 0000000..12eeaff --- /dev/null +++ b/man/read_input.Rd @@ -0,0 +1,22 @@ +% 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 new file mode 100644 index 0000000..214a384 --- /dev/null +++ b/publish_cran.R @@ -0,0 +1,36 @@ +# 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 05e0832..f2cdbe9 100644 --- a/renv.lock +++ b/renv.lock @@ -76,33 +76,6 @@ ], "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", @@ -114,51 +87,6 @@ ], "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", @@ -189,16 +117,6 @@ ], "Hash": "543776ae6848fde2f48ff3816d0628bc" }, - "brio": { - "Package": "brio", - "Version": "1.1.5", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R" - ], - "Hash": "c1ee497a6d999947c2c224ae46799b1a" - }, "bslib": { "Package": "bslib", "Version": "0.8.0", @@ -232,19 +150,6 @@ ], "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", @@ -323,16 +228,6 @@ ], "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", @@ -344,19 +239,6 @@ ], "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", @@ -417,16 +299,6 @@ "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", @@ -486,34 +358,6 @@ ], "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", @@ -540,30 +384,6 @@ ], "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", @@ -595,34 +415,6 @@ ], "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", @@ -725,13 +517,6 @@ ], "Hash": "4062982514dd797c7013124da49994c8" }, - "lpSolve": { - "Package": "lpSolve", - "Version": "5.6.21", - "Source": "Repository", - "Repository": "RSPM", - "Hash": "730a90bdc519fb0caff03df11218ddd8" - }, "magrittr": { "Package": "magrittr", "Version": "2.0.3", @@ -817,16 +602,6 @@ ], "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", @@ -859,32 +634,22 @@ ], "Hash": "0f9f0bb7e9cff9da0237c8bd206d40a2" }, - "openssl": { - "Package": "openssl", - "Version": "2.2.2", + "openxlsx2": { + "Package": "openxlsx2", + "Version": "1.9", "Source": "Repository", - "Repository": "RSPM", - "Requirements": [ - "askpass" - ], - "Hash": "d413e0fef796c9401a4419485f709ca1" - }, - "openxlsx": { - "Package": "openxlsx", - "Version": "4.2.7.1", - "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", + "R6", "Rcpp", "grDevices", - "methods", - "stats", + "magrittr", "stringi", "utils", "zip" ], - "Hash": "14304e44a0f90fa2d0f905472333c561" + "Hash": "f3e00e7d16abb500e63faee67b7dc1a7" }, "patchwork": { "Package": "patchwork", @@ -922,40 +687,6 @@ ], "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", @@ -966,68 +697,6 @@ ], "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", @@ -1044,32 +713,6 @@ ], "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", @@ -1136,16 +779,6 @@ ], "Hash": "3eec01f8b1dee337674b2e34ab1f9bc1" }, - "rprojroot": { - "Package": "rprojroot", - "Version": "2.0.4", - "Source": "Repository", - "Repository": "RSPM", - "Requirements": [ - "R" - ], - "Hash": "4c8415e0ec1e29f3f4f6fc108bef0144" - }, "sass": { "Package": "sass", "Version": "0.4.9", @@ -1213,31 +846,6 @@ ], "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", @@ -1272,30 +880,6 @@ ], "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", @@ -1315,29 +899,6 @@ ], "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", @@ -1399,13 +960,6 @@ ], "Hash": "c826c7c4241b6fc89ff55aaea3fa7491" }, - "whisker": { - "Package": "whisker", - "Version": "0.4.1", - "Source": "Repository", - "Repository": "RSPM", - "Hash": "c6abfa47a46d281a7d5159d0a8891e88" - }, "withr": { "Package": "withr", "Version": "3.0.1",