diff --git a/.github/workflows/pkgdown.yml b/.github/workflows/pkgdown.yaml similarity index 74% rename from .github/workflows/pkgdown.yml rename to .github/workflows/pkgdown.yaml index 22908e5..bfc9f4d 100644 --- a/.github/workflows/pkgdown.yml +++ b/.github/workflows/pkgdown.yaml @@ -4,12 +4,13 @@ on: push: branches: [main, master] pull_request: - branches: [main, master] release: types: [published] workflow_dispatch: -name: pkgdown +name: pkgdown.yaml + +permissions: read-all jobs: pkgdown: @@ -22,7 +23,7 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 @@ -34,13 +35,6 @@ jobs: with: extra-packages: any::pkgdown, local::. needs: website - - name: Install dependencies - run: | - install.packages("devtools") - system("git clone https://github.com/erblast/parcats.git") - devtools::install("parcats/", dependencies = TRUE) - shell: Rscript {0} - - name: Build site run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) @@ -48,8 +42,8 @@ jobs: - name: Deploy to GitHub pages 🚀 if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@v4.4.1 + uses: JamesIves/github-pages-deploy-action@v4.5.0 with: clean: false branch: gh-pages - folder: docs \ No newline at end of file + folder: docs 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 a0f5a7d..1b726bc 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ revdep/ inst/doc docker.sh docs/ -.DS_Store \ No newline at end of file +.DS_Store +docs diff --git a/DESCRIPTION b/DESCRIPTION index 84959ef..d77efb4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: parcats Title: Interactive Parallel Categories Diagrams for 'easyalluvial' -Version: 0.0.5 +Version: 0.1.0 Authors@R: person( "Bjoern", "Koneswarakantha", role = c("aut","cre"), email = "datistics@gmail.com", comment = c(ORCID = "0000-0003-4585-7799") ) URL: https://erblast.github.io/parcats/ BugReports: https://github.com/erblast/parcats/issues/ @@ -22,9 +22,9 @@ Suggests: spelling, plotly, shiny -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Imports: - easyalluvial (>= 0.2.1.0), + easyalluvial (>= 0.4.0), tidyr (>= 1.0.0), dplyr, purrr, diff --git a/NEWS.md b/NEWS.md index c58fd91..1135390 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +# parcats 0.1.0 +* adapt to easyalluvial v0.4.0 and ggplot2 v4.0.0 + # parcats 0.0.5 * update vignette * fix documentation diff --git a/R/parcats.R b/R/parcats.R index 1d4eaf5..bd39f0a 100644 --- a/R/parcats.R +++ b/R/parcats.R @@ -13,7 +13,7 @@ if(getRversion() >= "2.15.1"){ trace_hist_all = function(p, data_input){ - vars = p$data$x %>% levels() + vars = manip_get_ggplot_data(p)$x %>% levels() traces = list() @@ -24,7 +24,7 @@ trace_hist_all = function(p, data_input){ if(! is_pred){ is_num = is.numeric( data_input[[var]] ) }else{ - var_pred = names(data_input)[! names(data_input) %in% names(p$alluvial_params$dspace) ] + var_pred = names(data_input)[! names(data_input) %in% names(attr(p, "alluvial_params")$dspace) ] if(length(var_pred) > 1){ stop( paste('\n"data_input" should only contain explanatory and response variables, so response variable can be inferred. \nPotential response variables:', paste( var_pred, collapse = ', ') @@ -46,7 +46,7 @@ trace_hist_all = function(p, data_input){ } trace_rug_all = function(p, data_input){ - vars = p$data$x %>% levels() + vars = manip_get_ggplot_data(p)$x %>% levels() traces = list() @@ -62,7 +62,7 @@ trace_rug_all = function(p, data_input){ trace_rug = function(p, data_input, var){ - vars = p$data$x %>% levels + vars = manip_get_ggplot_data(p)$x %>% levels is_num = is.numeric(data_input[[var]]) @@ -100,7 +100,7 @@ trace_hist_mod = function(p, data_input, var){ df = p_hist$data - vars = p$data$x %>% levels + vars = manip_get_ggplot_data(p)$x %>% levels values = data_input[[var]] @@ -125,7 +125,7 @@ trace_hist_mod = function(p, data_input, var){ trace_var = list(trace_var) names(trace_var) <- paste0( var, '_dens') - lines_at = p$alluvial_params$dspace[[var]] %>% + lines_at = attr(p, "alluvial_params")$dspace[[var]] %>% unique() %>% sort() @@ -133,7 +133,7 @@ trace_hist_mod = function(p, data_input, var){ # labels need to be consistent {var}_{fill_label} so that we # can track the traces - fill_labels = p$data %>% + fill_labels = manip_get_ggplot_data(p) %>% filter( x == var) %>% select( value, fill_value) %>% distinct() %>% @@ -172,7 +172,7 @@ trace_hist_num = function(p, data_input, var){ df = p_hist$data - vars = p$data$x %>% levels + vars = manip_get_ggplot_data(p)$x %>% levels if(var == 'pred'){ @@ -180,7 +180,7 @@ trace_hist_num = function(p, data_input, var){ # labels need to be consistent {var}_{fill_label} so that we # can track the traces - fill_labels = p$data %>% + fill_labels = manip_get_ggplot_data(p) %>% filter( x == 'pred') %>% select(fill, value, fill_value) %>% mutate( rwn = as.numeric(fill) ) %>% @@ -194,7 +194,7 @@ trace_hist_num = function(p, data_input, var){ left_join( fill_labels, by = 'rwn') } - if( p$alluvial_type == 'model_response' & var != 'pred'){ + if( attr(p, "alluvial_type") == 'model_response' & var != 'pred'){ return( trace_hist_mod(p, data_input, var) ) } @@ -227,7 +227,7 @@ trace_hist_cat = function(p, data_input, var){ p_hist = easyalluvial::plot_hist(var = var, p = p, data_input = data_input) - df_label = p$data %>% + df_label = manip_get_ggplot_data(p) %>% filter( x == var ) %>% mutate( value = fct_drop(value) ) %>% select( value ) %>% @@ -260,7 +260,7 @@ trace_hist_cat = function(p, data_input, var){ lvl = levels(df[[var]]) - vars = p$data$x %>% levels + vars = manip_get_ggplot_data(p)$x %>% levels df = df %>% mutate( var_key = fct_relevel(var_key, lvl) ) %>% @@ -287,7 +287,7 @@ trace_imp = function(p, data_input, truncate_at = 50, color = 'darkgrey'){ p_imp = easyalluvial::plot_imp(p, data_input, truncate_at, color ) - df = p_imp$data + df = manip_get_ggplot_data(p_imp) if( ! 'const_values' %in% names(df) ){ df$const_values = NA @@ -297,7 +297,7 @@ trace_imp = function(p, data_input, truncate_at = 50, color = 'darkgrey'){ mutate_if( is.factor, as.character ) %>% arrange( perc ) %>% mutate( fill = ifelse(plotted == 'n', 'lightgrey', color) - , method = p$alluvial_params$method + , method = attr(p, "alluvial_params")$method , text = case_when( plotted == 'y' ~ 'alluvial' , method == 'pdp' ~ 'pdp' , TRUE ~ paste('fixed:', const_values) ) ) %>% @@ -334,8 +334,8 @@ trace_parcats = function(p , tickfont ){ - if(p$alluvial_type == 'model_response'){ - df = p$data %>% + if(attr(p, "alluvial_type") == 'model_response'){ + df = manip_get_ggplot_data(p) %>% arrange( desc(value) ) %>% mutate(value_str = as.character(value) , value_str = ifelse( x != 'pred', str_split(value_str, '\\\n'), value_str) @@ -345,7 +345,7 @@ trace_parcats = function(p , value = value_str) %>% select( - value_str) }else{ - df = p$data + df = manip_get_ggplot_data(p) } df = df %>% @@ -353,7 +353,7 @@ trace_parcats = function(p spread(x, value) %>% arrange(alluvial_id) - if (p$alluvial_params$fill_by == "values") { + if (attr(p, "alluvial_params")$fill_by == "values") { stop("fill_by = 'values' not supported in parcats") } @@ -482,7 +482,7 @@ create_layout_hist = function(trace_hist map_trace = function(p, trace_hist){ - df = p$data %>% + df = manip_get_ggplot_data(p) %>% mutate( x_value = map2_chr(x, value, function(x,y) paste0(x,'_' ,y) ) , trace_number = map(x_value, ~ which(names(trace_hist) == . ) ) , trace_number = map_int(trace_number, ~ ifelse( is_empty(.), NA, .) ) ) %>% @@ -641,9 +641,9 @@ parcats <- function(p, marginal_histograms = TRUE, data_input = NULL stop('data_input required if marginal_histograms == TRUE') } - if( imp == TRUE & is.null(data_input) & p$alluvial_type == 'model_response' ){ + if( imp == TRUE & is.null(data_input) & attr(p, "alluvial_type") == 'model_response' ){ stop('data_input required if imp == TRUE') - }else if(p$alluvial_type != 'model_response' | ! imp ){ + }else if(attr(p, "alluvial_type") != 'model_response' | ! imp ){ imp = FALSE offset_imp = 1 } @@ -654,7 +654,7 @@ parcats <- function(p, marginal_histograms = TRUE, data_input = NULL domain = list( y = c(0, 1) ) } - if( imp & p$alluvial_type == 'model_response' ){ + if( imp & attr(p, "alluvial_type") == 'model_response' ){ domain$x = c(0, offset_imp - 0.05 ) traces_imp = trace_imp(p, data_input, truncate_at = 50, color = 'darkgrey') }else{ @@ -718,7 +718,7 @@ parcats <- function(p, marginal_histograms = TRUE, data_input = NULL p_imp = easyalluvial::plot_imp(p, data_input) - max_perc = p_imp$data$perc %>% max() + max_perc = manip_get_ggplot_data(p_imp)$perc %>% max() for( i in seq(1, length(traces_imp) ) ){ l = list( xref = 'x99' diff --git a/cran-comments.md b/cran-comments.md index f39ae31..4a7fda0 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,50 +1,5 @@ -# Resubmission +## R CMD check results +0 errors | 0 warnings | 0 note -Please add \value to .Rd files regarding exported methods and explain -the functions results in the documentation. Please write about the -structure of the output (class) and also what the output means. (If a -function does not return a value, please document that too, e.g. -\value{No return value, called for side effects} or similar) -Missing Rd-tags: - parcats-shiny.Rd: \value - parcats_demo.Rd: \value - -\dontrun{} should only be used if the example really cannot be executed -(e.g. because of missing additional software, missing API keys, ...) by -the user. That's why wrapping examples in \dontrun{} adds the comment -("# Not run:") as a warning for the user. Does not seem necessary. -Please replace \dontrun with \donttest. -Please unwrap the examples if they are executable in < 5 sec, or replace -dontrun{} with \donttest{}. --> man/parcats.Rd - -- return value was added -- switched to donttest -- conditional execution of parcats example that requires suggested package - -# parcats 0.0.5 -Resubmit to CRAN after being archived. -Dependency 'easyalluvial' on CRAN again - -## revdepcheck results -no reverse dependencies - -## Test Environments -* local macOS M1 R 4.3.2 -* github actions macos-latest R 4.3.2 -* Rhub Windows Server 2022, R-devel, 64 bit -* WinBuilder R 4.3.2 -* WinBuilder R devel - -## Test Results - -Maintainer: ‘Bjoern Koneswarakantha ’ - -New submission - -Package was archived on CRAN - -## Reverse Dependencies - -no reverse dependencies +locally, Rhub, gh-actions diff --git a/inst/WORDLIST b/inst/WORDLIST index f2d1734..eee51f7 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,4 +1,3 @@ -AppVeyor Codecov Htmlwidget Htmlwidgets @@ -8,6 +7,7 @@ easyalluvial easyalluvial’ elementid freeform +ggplot github htmlwidget js diff --git a/parcats.Rproj b/parcats.Rproj index eaa6b81..75611f8 100644 --- a/parcats.Rproj +++ b/parcats.Rproj @@ -1,4 +1,5 @@ Version: 1.0 +ProjectId: 435c9099-d948-41ea-8fa6-f32013c0c0ad RestoreWorkspace: Default SaveWorkspace: Default diff --git a/tests/testthat/test_parcats.R b/tests/testthat/test_parcats.R index 58e701e..01ecf6a 100644 --- a/tests/testthat/test_parcats.R +++ b/tests/testthat/test_parcats.R @@ -2,6 +2,11 @@ context('parcats') +mtcars2 <- easyalluvial::mtcars2 +titanic <- easyalluvial::titanic +quarterly_flights <- easyalluvial::quarterly_flights +quarterly_sunspots <- easyalluvial::quarterly_sunspots + test_that('parcats_alluvial_wide' ,{ @@ -144,4 +149,4 @@ test_that('parcats_alluvial_model_response' # grid = add_marginal_histograms(p, df) -}) \ No newline at end of file +}) diff --git a/vignettes/parcats.Rmd b/vignettes/parcats.Rmd index 4e71b87..88f0425 100644 --- a/vignettes/parcats.Rmd +++ b/vignettes/parcats.Rmd @@ -28,6 +28,9 @@ suppressPackageStartupMessages(require(parcats)) ### Parcats from alluvial from data in wide format ```{r eval = TRUE, fig.width = 10, fig.height = 7} + +data("mtcars2", package = "easyalluvial") + p <- alluvial_wide(mtcars2, max_variables = 5) parcats(p, marginal_histograms = TRUE, data_input = mtcars2)