Skip to content

Commit 58694ac

Browse files
committed
WIP
1 parent 5b73cc3 commit 58694ac

File tree

5 files changed

+93
-32
lines changed

5 files changed

+93
-32
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: jjstatsplot
33
Title: Wrapper for ggstatsplot
4-
Version: 0.0.3.19
4+
Version: 0.0.3.20
55
Date: 2024-05-30
66
Authors@R:
77
person(given = "Serdar",

jamovi/0000.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Wrapper for ggstatsplot
33
name: jjstatsplot
4-
version: 0.0.3.19
4+
version: 0.0.3.20
55
jms: '1.0'
66
authors:
77
- Serdar Balci

vignettes/categorical-plots.Rmd

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ variables. The example below compares the number of cylinders (`cyl`)
2424
across transmission types (`am`).
2525

2626
```{r}
27-
jjbarstats(data = mtcars, group = cyl, grvar = am)
27+
jjbarstats(data = mtcars, dep = cyl, group = am, grvar = NULL)
2828
```
2929

3030
## Pie charts with `jjpiestats()`
@@ -33,7 +33,7 @@ jjbarstats(data = mtcars, group = cyl, grvar = am)
3333
pie chart.
3434

3535
```{r}
36-
jjpiestats(data = mtcars, dep = cyl, group = am)
36+
jjpiestats(data = mtcars, dep = cyl, group = am, grvar = NULL)
3737
```
3838

3939
## Dot charts with `jjdotplotstats()`
@@ -42,10 +42,8 @@ jjpiestats(data = mtcars, dep = cyl, group = am)
4242
plot horsepower (`hp`) by engine configuration (`vs`).
4343

4444
```{r}
45-
jjdotplotstats(data = mtcars, dep = hp, group = vs)
45+
jjdotplotstats(data = mtcars, dep = hp, group = vs, grvar = NULL)
4646
```
4747

4848
Each function returns a results object whose `plot` element contains the
4949
`ggplot2` visualisation.
50-
51-
Lines changed: 86 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,113 @@
11
---
2-
title: "Continuous Variable Comparisons"
2+
title: "Categorical Plot Functions"
33
output: rmarkdown::html_vignette
44
vignette: >
5-
%\VignetteIndexEntry{Continuous Variable Comparisons}
5+
%\VignetteIndexEntry{Categorical Plot Functions}
66
%\VignetteEngine{rmarkdown}
77
%\VignetteEncoding{UTF-8}
88
---
99

1010
```{r setup, include=FALSE}
1111
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)
12+
library(dplyr)
1213
library(jjstatsplot)
14+
library(ggstatsplot)
1315
data(mtcars)
16+
17+
# Convert relevant variables to factors for categorical analysis
18+
mtcars$cyl <- as.factor(mtcars$cyl)
19+
mtcars$am <- as.factor(mtcars$am)
20+
mtcars$vs <- as.factor(mtcars$vs)
1421
```
1522

16-
This article focuses on functions that compare continuous variables.
23+
This vignette demonstrates the categorical plot functions available in the jjstatsplot package. These functions are designed to work within the jamovi interface, but we can demonstrate their underlying functionality using the ggstatsplot functions they wrap.
24+
25+
## Bar charts with `jjbarstats()`
26+
27+
The `jjbarstats()` function creates bar charts and performs chi-squared tests to compare categorical variables. It wraps `ggstatsplot::ggbarstats()`.
28+
29+
```{r, fig.width=7, fig.height=5}
30+
# Underlying function that jjbarstats() wraps
31+
ggstatsplot::ggbarstats(
32+
data = mtcars,
33+
x = cyl,
34+
y = am,
35+
title = "Cylinders by Transmission Type"
36+
)
37+
```
1738

18-
## Comparing groups with `jjbetweenstats()`
39+
## Pie charts with `jjpiestats()`
1940

20-
`jjbetweenstats()` combines box and violin plots to compare a continuous
21-
response across groups. Statistical tests such as ANOVA or their
22-
non-parametric equivalents are performed automatically depending on the
23-
`typestatistics` argument.
41+
The `jjpiestats()` function creates pie charts for categorical data visualization. It wraps `ggstatsplot::ggpiestats()`.
2442

25-
```{r}
26-
jjbetweenstats(data = mtcars, dep = mpg, group = cyl)
43+
```{r, fig.width=7, fig.height=5}
44+
# Underlying function that jjpiestats() wraps
45+
ggstatsplot::ggpiestats(
46+
data = mtcars,
47+
x = cyl,
48+
y = am,
49+
title = "Distribution of Cylinders by Transmission"
50+
)
2751
```
2852

29-
## Repeated measures with `jjwithinstats()`
53+
## Dot charts with `jjdotplotstats()`
3054

31-
For paired or repeated observations, `jjwithinstats()` displays the
32-
measurements for each condition alongside the results of a paired test.
33-
Below we compare miles-per-gallon recorded in two hypothetical
34-
conditions represented by `mpg` and `hp` just for demonstration.
55+
The `jjdotplotstats()` function shows group comparisons using dot plots. It wraps `ggstatsplot::ggdotplotstats()`.
3556

36-
```{r}
37-
jjwithinstats(data = mtcars, dep1 = mpg, dep2 = hp)
57+
```{r, fig.width=7, fig.height=5}
58+
# Underlying function that jjdotplotstats() wraps
59+
ggstatsplot::ggdotplotstats(
60+
data = mtcars,
61+
x = hp,
62+
y = vs,
63+
title = "Horsepower by Engine Configuration"
64+
)
3865
```
3966

40-
## Histograms with `jjhistostats()`
67+
## Within-group comparisons with `jjwithinstats()`
4168

42-
`jjhistostats()` produces histograms and overlays the results of a test
43-
for normality. The example below shows the distribution of engine
44-
horsepower.
69+
The `jjwithinstats()` function compares repeated measurements within groups. It wraps `ggstatsplot::ggwithinstats()`.
4570

46-
```{r}
47-
jjhistostats(data = mtcars, dep = hp)
71+
```{r, fig.width=8, fig.height=6}
72+
# Create long format data for within-group comparison
73+
library(tidyr)
74+
mtcars_long <- mtcars %>%
75+
select(mpg, hp, wt, qsec) %>%
76+
mutate(id = row_number()) %>%
77+
pivot_longer(cols = c(mpg, hp, wt, qsec),
78+
names_to = "measure",
79+
values_to = "value") %>%
80+
# Standardize values for comparison
81+
group_by(measure) %>%
82+
mutate(value = scale(value)[,1]) %>%
83+
ungroup()
84+
85+
# Underlying function that jjwithinstats() wraps
86+
ggstatsplot::ggwithinstats(
87+
data = mtcars_long,
88+
x = measure,
89+
y = value,
90+
paired = TRUE,
91+
id = id,
92+
title = "Comparison of Standardized Car Measurements"
93+
)
4894
```
4995

96+
## Usage in jamovi
97+
98+
These functions are designed to be used through the jamovi graphical interface, where they provide:
99+
100+
- Interactive parameter selection
101+
- Automatic data type handling
102+
- Integrated results display
103+
- Export capabilities
104+
105+
To use these functions in jamovi:
106+
107+
1. Install the jjstatsplot module
108+
2. Load your data
109+
3. Navigate to the JJStatsPlot menu
110+
4. Select the appropriate plot type
111+
5. Configure variables and options through the interface
50112

113+
The jamovi interface handles parameter validation, data preprocessing, and result presentation automatically.

vignettes/correlations-scatterplots.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ and reports the associated tests. Here we look at the relationships
2323
between `mpg`, `hp` and `wt` in the `mtcars` data.
2424

2525
```{r}
26-
jjcorrmat(data = mtcars, dep = c(mpg, hp, wt))
26+
jjcorrmat(data = mtcars, dep = c(mpg, hp, wt), grvar = NULL)
2727
```
2828

2929
## Scatter plots with `jjscatterstats()`
@@ -32,7 +32,7 @@ jjcorrmat(data = mtcars, dep = c(mpg, hp, wt))
3232
textual output describing the correlation and regression statistics.
3333

3434
```{r}
35-
jjscatterstats(data = mtcars, dep = mpg, group = hp)
35+
jjscatterstats(data = mtcars, dep = mpg, group = hp, grvar = NULL)
3636
```
3737

3838

0 commit comments

Comments
 (0)