Skip to content

Commit 353b0e0

Browse files
committed
2 parents 32b4c39 + d7986b0 commit 353b0e0

File tree

7 files changed

+376
-0
lines changed

7 files changed

+376
-0
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
#
4+
# NOTE: This workflow is overkill for most R packages and
5+
# check-standard.yaml is likely a better choice.
6+
# usethis::use_github_action("check-standard") will install it.
7+
on:
8+
push:
9+
branches: [main, master]
10+
pull_request:
11+
12+
name: R-CMD-check.yaml
13+
14+
permissions: read-all
15+
16+
jobs:
17+
R-CMD-check:
18+
runs-on: ${{ matrix.config.os }}
19+
20+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
21+
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
config:
26+
- {os: macos-latest, r: 'release'}
27+
28+
- {os: windows-latest, r: 'release'}
29+
# use 4.0 or 4.1 to check with rtools40's older compiler
30+
- {os: windows-latest, r: 'oldrel-4'}
31+
32+
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
33+
- {os: ubuntu-latest, r: 'release'}
34+
- {os: ubuntu-latest, r: 'oldrel-1'}
35+
- {os: ubuntu-latest, r: 'oldrel-2'}
36+
- {os: ubuntu-latest, r: 'oldrel-3'}
37+
- {os: ubuntu-latest, r: 'oldrel-4'}
38+
39+
env:
40+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
41+
R_KEEP_PKG_SOURCE: yes
42+
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- uses: r-lib/actions/setup-pandoc@v2
47+
48+
- uses: r-lib/actions/setup-r@v2
49+
with:
50+
r-version: ${{ matrix.config.r }}
51+
http-user-agent: ${{ matrix.config.http-user-agent }}
52+
use-public-rspm: true
53+
54+
- uses: r-lib/actions/setup-r-dependencies@v2
55+
with:
56+
extra-packages: any::rcmdcheck
57+
needs: check
58+
59+
- uses: r-lib/actions/check-r-package@v2
60+
with:
61+
upload-snapshots: true
62+
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

.github/workflows/test-coverage.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
8+
name: test-coverage.yaml
9+
10+
permissions: read-all
11+
12+
jobs:
13+
test-coverage:
14+
runs-on: ubuntu-latest
15+
env:
16+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: r-lib/actions/setup-r@v2
22+
with:
23+
use-public-rspm: true
24+
25+
- uses: r-lib/actions/setup-r-dependencies@v2
26+
with:
27+
extra-packages: any::covr, any::xml2
28+
needs: coverage
29+
30+
- name: Test coverage
31+
run: |
32+
cov <- covr::package_coverage(
33+
quiet = FALSE,
34+
clean = FALSE,
35+
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
36+
)
37+
covr::to_cobertura(cov)
38+
shell: Rscript {0}
39+
40+
- uses: codecov/codecov-action@v4
41+
with:
42+
# Fail if error if not on PR, or if on PR and token is given
43+
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
44+
file: ./cobertura.xml
45+
plugin: noop
46+
disable_search: true
47+
token: ${{ secrets.CODECOV_TOKEN }}
48+
49+
- name: Show testthat output
50+
if: always()
51+
run: |
52+
## --------------------------------------------------------------------
53+
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
54+
shell: bash
55+
56+
- name: Upload test results
57+
if: failure()
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: coverage-test-failures
61+
path: ${{ runner.temp }}/package

R/flowchart.b.R

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#' @title Study Flowchart
2+
#' @importFrom R6 R6Class
3+
#' @import jmvcore
4+
#'
5+
flowchartClass <- if (requireNamespace('jmvcore')) R6::R6Class(
6+
"flowchartClass",
7+
inherit = flowchartBase,
8+
private = list(
9+
.run = function() {
10+
11+
# Show initial help message if no variables selected
12+
if (is.null(self$options$nodes)) {
13+
todo <- "
14+
<br>Welcome to ClinicoPath Flowchart Creator
15+
<br><br>
16+
This tool helps create CONSORT-style flow diagrams showing participant flow through studies.
17+
<br><br>
18+
To create a flowchart:
19+
1. Add variables containing node descriptions to 'Node Data'
20+
2. Add corresponding count variables to 'Node Counts'
21+
3. Adjust direction and style options as needed
22+
<hr>
23+
"
24+
html <- self$results$todo
25+
html$setContent(todo)
26+
return()
27+
}
28+
29+
if (nrow(self$data) == 0)
30+
stop('Data contains no (complete) rows')
31+
32+
# Prepare data for plotting
33+
plotData <- list(
34+
"data" = self$data,
35+
"nodes" = self$options$nodes,
36+
"counts" = self$options$counts,
37+
"direction" = self$options$direction,
38+
"style" = self$options$style,
39+
"showCounts" = self$options$showCounts,
40+
"title" = self$options$title
41+
)
42+
43+
# Save state for plot function
44+
image <- self$results$diagram
45+
image$setState(plotData)
46+
},
47+
48+
.plot = function(image, ggtheme, theme, ...) {
49+
# Get plot data
50+
plotData <- image$state
51+
52+
# Create nodes and edges dataframe
53+
nodes_df <- data.frame(
54+
id = seq_along(plotData$nodes),
55+
label = paste0(
56+
plotData$data[[plotData$nodes[1]]],
57+
ifelse(
58+
plotData$showCounts,
59+
paste0("\n(n=", plotData$data[[plotData$counts[1]]], ")"),
60+
""
61+
)
62+
),
63+
stringsAsFactors = FALSE
64+
)
65+
66+
edges_df <- data.frame(
67+
from = head(nodes_df$id, -1),
68+
to = tail(nodes_df$id, -1),
69+
stringsAsFactors = FALSE
70+
)
71+
72+
# Create graph
73+
graph <- DiagrammeR::create_graph()
74+
graph <- DiagrammeR::add_nodes_from_table(
75+
graph,
76+
nodes_df,
77+
label_col = "label"
78+
)
79+
graph <- DiagrammeR::add_edges_from_table(
80+
graph,
81+
edges_df,
82+
from_col = "from",
83+
to_col = "to"
84+
)
85+
86+
# Set graph attributes based on style
87+
if (plotData$style == "detailed") {
88+
graph <- DiagrammeR::set_global_graph_attrs(
89+
graph,
90+
"layout", plotData$direction,
91+
"rankdir", plotData$direction,
92+
"splines", "ortho"
93+
)
94+
} else {
95+
graph <- DiagrammeR::set_global_graph_attrs(
96+
graph,
97+
"layout", plotData$direction,
98+
"rankdir", plotData$direction
99+
)
100+
}
101+
102+
# Add title
103+
graph <- DiagrammeR::add_global_graph_attrs(
104+
graph,
105+
"label", plotData$title,
106+
"labelloc", "t"
107+
)
108+
109+
# Render graph
110+
print(graph)
111+
TRUE
112+
}
113+
)
114+
)

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ ClinicoPath jamovi module Descriptives
55
See https://sbalci.github.io/ClinicoPathJamoviModule/
66

77

8+
9+
[![R-CMD-check](https://github.com/sbalci/ClinicoPathDescriptives/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/sbalci/ClinicoPathDescriptives/actions/workflows/R-CMD-check.yaml)
10+
11+
[![Codecov test coverage](https://codecov.io/gh/sbalci/ClinicoPathDescriptives/graph/badge.svg)](https://app.codecov.io/gh/sbalci/ClinicoPathDescriptives)
12+

jamovi/flowchart.a.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
name: flowchart
3+
title: Study Flowchart
4+
menuGroup: Exploration
5+
menuSubgroup: ClinicoPath Descriptive Plots
6+
version: '1.0.0'
7+
jas: '1.2'
8+
9+
options:
10+
- name: data
11+
type: Data
12+
description:
13+
R: >
14+
The data as a data frame.
15+
16+
- name: title
17+
title: Flowchart Title
18+
type: String
19+
default: "Study Flow Diagram"
20+
21+
- name: nodes
22+
title: Node Data
23+
type: Variables
24+
suggested: [nominal]
25+
permitted: [factor]
26+
description:
27+
R: >
28+
Variables containing node labels/descriptions
29+
30+
- name: counts
31+
title: Node Counts
32+
type: Variables
33+
suggested: [continuous]
34+
permitted: [numeric]
35+
description:
36+
R: >
37+
Variables containing counts for each node
38+
39+
- name: direction
40+
title: Direction
41+
type: List
42+
options:
43+
- title: Top to Bottom
44+
name: tb
45+
- title: Left to Right
46+
name: lr
47+
default: tb
48+
49+
- name: style
50+
title: Style
51+
type: List
52+
options:
53+
- title: Simple
54+
name: simple
55+
- title: Detailed
56+
name: detailed
57+
default: simple
58+
59+
- name: showCounts
60+
title: Show Counts
61+
type: Bool
62+
default: true
63+
...

jamovi/flowchart.r.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: flowchart
3+
title: Study Flowchart
4+
jrs: '1.1'
5+
6+
items:
7+
- name: todo
8+
title: To Do
9+
type: Html
10+
11+
- name: diagram
12+
title: 'Flowchart Diagram'
13+
type: Image
14+
width: 800
15+
height: 600
16+
renderFun: .plot
17+
requiresData: true
18+
clearWith:
19+
- nodes
20+
- counts
21+
- direction
22+
- style
23+
- showCounts
24+
25+
- name: diagramCode
26+
title: 'Diagram Code'
27+
type: Preformatted
28+
visible: false
29+
30+
refs:
31+
- ClinicoPathJamoviModule
32+
33+
...

jamovi/flowchart.u.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
title: Study Flowchart
2+
name: flowchart
3+
jus: '3.0'
4+
stage: 0
5+
compilerMode: tame
6+
children:
7+
- type: VariableSupplier
8+
persistentItems: false
9+
stretchFactor: 1
10+
children:
11+
- type: TargetLayoutBox
12+
label: Node Data
13+
children:
14+
- type: VariablesListBox
15+
name: nodes
16+
isTarget: true
17+
- type: TargetLayoutBox
18+
label: Node Counts
19+
children:
20+
- type: VariablesListBox
21+
name: counts
22+
isTarget: true
23+
- type: CollapseBox
24+
label: Options
25+
collapsed: true
26+
children:
27+
- type: LayoutBox
28+
margin: large
29+
children:
30+
- type: TextBox
31+
name: title
32+
format: string
33+
- type: ComboBox
34+
name: direction
35+
- type: ComboBox
36+
name: style
37+
- type: CheckBox
38+
name: showCounts

0 commit comments

Comments
 (0)