Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions .github/workflows/pkgdown.yml → .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -22,7 +23,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -34,22 +35,15 @@ 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)
shell: Rscript {0}

- 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
folder: docs
95 changes: 95 additions & 0 deletions .github/workflows/rhub.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ revdep/
inst/doc
docker.sh
docs/
.DS_Store
.DS_Store
docs
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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/
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
46 changes: 23 additions & 23 deletions R/parcats.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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 = ', ')
Expand All @@ -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()

Expand All @@ -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]])

Expand Down Expand Up @@ -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]]

Expand All @@ -125,15 +125,15 @@ 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()

# we have to rejoin with fill labels
# 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() %>%
Expand Down Expand Up @@ -172,15 +172,15 @@ 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'){

# we have to rejoin with fill labels
# 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) ) %>%
Expand All @@ -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) )
}

Expand Down Expand Up @@ -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 ) %>%
Expand Down Expand Up @@ -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) ) %>%
Expand All @@ -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
Expand All @@ -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) ) ) %>%
Expand Down Expand Up @@ -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)
Expand All @@ -345,15 +345,15 @@ trace_parcats = function(p
, value = value_str) %>%
select( - value_str)
}else{
df = p$data
df = manip_get_ggplot_data(p)
}

df = df %>%
select( - fill_value, - fill ) %>%
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")
}

Expand Down Expand Up @@ -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, .) ) ) %>%
Expand Down Expand Up @@ -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
}
Expand All @@ -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{
Expand Down Expand Up @@ -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'
Expand Down
Loading
Loading