Skip to content

Commit

Permalink
reduce size of the tarball; resubmit
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Apr 12, 2021
1 parent 76c332c commit adb965d
Show file tree
Hide file tree
Showing 67 changed files with 267 additions and 459 deletions.
2 changes: 1 addition & 1 deletion CRAN-RELEASE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This package was submitted to CRAN on 2021-04-12.
Once it is accepted, delete this file and tag the release (commit 312f97bc).
Once it is accepted, delete this file and tag the release (commit 76c332ca).
153 changes: 37 additions & 116 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ options(
knitr::opts_chunk$set(
collapse = TRUE,
dpi = 300,
dpi = 150, # change to 300 once on CRAN
warning = FALSE,
message = FALSE,
out.width = "100%",
Expand Down Expand Up @@ -232,43 +232,17 @@ ggbetweenstats(
`r emo::ji("check")` Bayesian estimation <br>

A number of other arguments can be specified to make this plot even more
informative or change some of the default options.
informative or change some of the default options. Additionally, there is also a
`grouped_` variant of this function that makes it easy to repeat the same
operation across a **single** grouping variable:

```{r ggbetweenstats2}
# for reproducibility
set.seed(123)
library(ggplot2)
# plot
ggbetweenstats(
data = ToothGrowth,
x = supp,
y = len,
type = "r", # robust statistics
k = 3, # number of decimal places for statistical results
xlab = "Supplement type", # label for the x-axis variable
ylab = "Tooth length", # label for the y-axis variable
title = "The Effect of Vitamin C on Tooth Growth", # title text for the plot
ggtheme = ggthemes::theme_fivethirtyeight(), # choosing a different theme
ggstatsplot.layer = FALSE, # turn off `ggstatsplot` theme layer
package = "wesanderson", # package from which color palette is to be taken
palette = "Darjeeling1" # choosing a different color palette
)
```

Additionally, there is also a `grouped_` variant of this function that makes it
easy to repeat the same operation across a **single** grouping variable:

```{r ggbetweenstats3, fig.height = 14, fig.width = 12}
```{r ggbetweenstats2, fig.height = 8, fig.width = 12}
# for reproducibility
set.seed(123)
# plot
grouped_ggbetweenstats(
data = dplyr::filter(
.data = movies_long,
genre %in% c("Action", "Action Comedy", "Action Drama", "Comedy")
),
data = dplyr::filter(movies_long, genre %in% c("Action", "Comedy")),
x = mpaa,
y = length,
grouping.var = genre, # grouping variable
Expand All @@ -282,7 +256,7 @@ grouped_ggbetweenstats(
caption = substitute(paste(italic("Source"), ": IMDb (Internet Movie Database)")),
palette = "default_jama",
package = "ggsci",
plotgrid.args = list(nrow = 2),
plotgrid.args = list(nrow = 1),
annotation.args = list(title = "Differences in movie length by mpaa ratings for different genres")
)
```
Expand Down Expand Up @@ -503,16 +477,13 @@ gghistostats(
There is also a `grouped_` variant of this function that makes it
easy to repeat the same operation across a **single** grouping variable:

```{r gghistostats2, fig.height = 10, fig.width = 10}
```{r gghistostats2, fig.height = 6, fig.width = 10}
# for reproducibility
set.seed(123)
# plot
grouped_gghistostats(
data = dplyr::filter(
.data = movies_long,
genre %in% c("Action", "Action Comedy", "Action Drama", "Comedy")
),
data = dplyr::filter(movies_long, genre %in% c("Action", "Comedy")),
x = budget,
test.value = 50,
type = "nonparametric",
Expand All @@ -523,7 +494,7 @@ grouped_gghistostats(
ggtheme = ggthemes::theme_tufte(),
# modify the defaults from `ggstatsplot` for each plot
ggplot.component = ggplot2::labs(caption = "Source: IMDB.com"),
plotgrid.args = list(nrow = 2),
plotgrid.args = list(nrow = 1),
annotation.args = list(title = "Movies budgets for different genres")
)
```
Expand Down Expand Up @@ -601,7 +572,7 @@ As with the rest of the functions in this package, there is also a `grouped_`
variant of this function to facilitate looping the same operation for all levels
of a single grouping variable.

```{r ggdotplotstats2, fig.height = 8, fig.width = 12}
```{r ggdotplotstats2, fig.height = 6, fig.width = 12}
# for reproducibility
set.seed(123)
Expand Down Expand Up @@ -660,13 +631,13 @@ The available marginal distributions are-

Number of other arguments can be specified to modify this basic plot-

```{r ggscatterstats2, fig.width=8}
```{r ggscatterstats2, fig.width=10}
# for reproducibility
set.seed(123)
# plot
ggscatterstats(
data = dplyr::filter(.data = movies_long, genre == "Action"),
data = dplyr::filter(movies_long, genre == "Action"),
x = budget,
y = rating,
type = "robust", # type of test that needs to be run
Expand All @@ -691,16 +662,13 @@ note that, as opposed to the other functions, this function does not return a
using `ggplot.component` argument (available for all functions, but especially
useful here):

```{r ggscatterstats3, fig.height = 12, fig.width = 14}
```{r ggscatterstats3, fig.height = 6, fig.width = 14}
# for reproducibility
set.seed(123)
# plot
grouped_ggscatterstats(
data = dplyr::filter(
.data = movies_long,
genre %in% c("Action", "Action Comedy", "Action Drama", "Comedy")
),
data = dplyr::filter(movies_long, genre %in% c("Action", "Comedy")),
x = rating,
y = length,
grouping.var = genre, # grouping variable
Expand All @@ -711,8 +679,8 @@ grouped_ggscatterstats(
ggplot.component = list(
ggplot2::scale_x_continuous(breaks = seq(2, 9, 1), limits = (c(2, 9)))
),
plotgrid.args = list(nrow = 2),
annotation.args = list(title = "Relationship between movie length by IMDB ratings for different genres")
plotgrid.args = list(nrow = 1),
annotation.args = list(title = "Relationship between movie length and IMDB ratings")
)
```

Expand Down Expand Up @@ -765,16 +733,13 @@ minimum, median, and maximum number of pairs used for correlation tests.
There is also a `grouped_` variant of this function that makes it
easy to repeat the same operation across a **single** grouping variable:

```{r ggcorrmat2, fig.height = 10, fig.width = 10}
```{r ggcorrmat2, fig.height = 6, fig.width = 10}
# for reproducibility
set.seed(123)
# plot
grouped_ggcorrmat(
data = dplyr::filter(
.data = movies_long,
genre %in% c("Action", "Action Comedy", "Action Drama", "Comedy")
),
data = dplyr::filter(movies_long, genre %in% c("Action", "Comedy")),
type = "robust", # correlation method
colors = c("#cbac43", "white", "#550000"),
grouping.var = genre, # grouping variable
Expand Down Expand Up @@ -844,6 +809,8 @@ ggpiestats(
data = mtcars,
x = am,
y = cyl,
package = "wesanderson",
palette = "Royal1",
title = "Dataset: Motor Trend Car Road Tests", # title for the plot
legend.title = "Transmission", # title for the legend
caption = substitute(paste(italic("Source"), ": 1974 Motor Trend US magazine"))
Expand All @@ -859,55 +826,23 @@ ggpiestats(
`r emo::ji("check")` Bayesian hypothesis-testing <br>
`r emo::ji("check")` Bayesian estimation <br>

In case of repeated measures designs, setting `paired = TRUE` will produce
results from McNemar's chi-squared test-

```{r ggpiestats2, fig.height=4}
# for reproducibility
set.seed(123)
# data
df_paired <-
data.frame(
"before" = c("Approve", "Approve", "Disapprove", "Disapprove"),
"after" = c("Approve", "Disapprove", "Approve", "Disapprove"),
counts = c(794, 150, 86, 570),
check.names = FALSE
)
# plot
ggpiestats(
data = df_paired,
x = before,
y = after,
counts = counts,
title = "Survey results before and after the intervention",
label = "both",
paired = TRUE, # within-subjects design
package = "wesanderson",
palette = "Royal1"
)
```

Additionally, there is also a `grouped_` variant of this function that makes it
There is also a `grouped_` variant of this function that makes it
easy to repeat the same operation across a **single** grouping variable.
Following example is a case where the theoretical question is about proportions
for different levels of a single nominal variable:

```{r ggpiestats3, fig.height = 10, fig.width = 10}
```{r ggpiestats2, fig.height = 6, fig.width = 10}
# for reproducibility
set.seed(123)
# plot
grouped_ggpiestats(
data = movies_long,
x = genre,
grouping.var = mpaa, # grouping variable
data = mtcars,
x = cyl,
grouping.var = am, # grouping variable
label.repel = TRUE, # repel labels (helpful for overlapping labels)
package = "ggsci", # package from which color palette is to be taken
palette = "default_ucscgb", # choosing a different color palette
annotation.args = list(title = "Composition of MPAA ratings for different genres"),
plotgrid.args = list(nrow = 2)
palette = "default_ucscgb" # choosing a different color palette
)
```

Expand Down Expand Up @@ -972,33 +907,20 @@ ggbarstats(

And, needless to say, there is also a `grouped_` variant of this function-

```{r ggbarstats2, fig.height = 12, fig.width = 10}
```{r ggbarstats2, fig.height = 6, fig.width = 12}
# setup
set.seed(123)
# smaller dataset
df <-
dplyr::filter(
.data = forcats::gss_cat,
race %in% c("Black", "White"),
relig %in% c("Protestant", "Catholic", "None"),
!partyid %in% c("No answer", "Don't know", "Other party")
)
# plot
grouped_ggbarstats(
data = df,
x = relig,
y = partyid,
grouping.var = race,
label = "both",
xlab = "Party affiliation",
data = mtcars,
x = am,
y = cyl,
grouping.var = vs,
package = "wesanderson",
palette = "Darjeeling2",
ggtheme = ggthemes::theme_tufte(base_size = 12),
ggstatsplot.layer = FALSE,
annotation.args = list(title = "Race, religion, and political affiliation"),
plotgrid.args = list(nrow = 2)
ggstatsplot.layer = FALSE
)
```

Expand Down Expand Up @@ -1241,8 +1163,7 @@ the following packages that manage different aspects of statistical analyses:
## `statsExpressions`

The `statsExpressions` package forms the statistical backend that processes data
and creates expressions containing results from statistical tests and are by
default displayed in as plot **subtitle** and **caption**.
and creates expressions containing results from statistical tests.

For more exhaustive documentation for this package, see:
<https://indrajeetpatil.github.io/statsExpressions/>
Expand All @@ -1258,8 +1179,8 @@ For more exhaustive documentation for this package, see:

## `ipmisc`

The `ipmisc` package contains some of the data wrangling/cleaning functions and
a few other miscellaneous functions.
The `ipmisc` package contains the data wrangling/cleaning functions and a few
other miscellaneous functions.

For more exhaustive documentation for this package, see:
<https://indrajeetpatil.github.io/ipmisc/>
Expand All @@ -1282,7 +1203,7 @@ package.

The hexsticker was generously designed by Sarah Otterstetter (Max Planck
Institute for Human Development, Berlin). This package has also benefited from
the larger `rstats` community on Twitter and StackOverflow.
the larger `rstats` community on Twitter and `StackOverflow`.

Thanks are also due to my postdoc advisers (Mina Cikara and Fiery Cushman at
Harvard University; Iyad Rahwan at Max Planck Institute for Human Development)
Expand Down
Loading

4 comments on commit adb965d

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-raw/Titanic_full.R:16:10: warning: 1:nrow(...) is likely to be wrong in the empty edge case, use seq_len.

df[rep(1:nrow(df), rep), ]
         ^

R/ggbarstats.R:44:1: style: functions should have cyclomatic complexity of less than 15, this has 16.

ggbarstats <- function(data,
^

R/ggbetweenstats.R:165:1: style: functions should have cyclomatic complexity of less than 15, this has 24.

ggbetweenstats <- function(data,
^

R/ggcoefstats.R:133:1: style: functions should have cyclomatic complexity of less than 15, this has 43.

ggcoefstats <- function(x,
^

R/ggcorrmat.R:97:1: style: functions should have cyclomatic complexity of less than 15, this has 18.

ggcorrmat <- function(data,
^

R/ggpiestats.R:71:1: style: functions should have cyclomatic complexity of less than 15, this has 29.

ggpiestats <- function(data,
^

R/ggscatterstats.R:96:1: style: functions should have cyclomatic complexity of less than 15, this has 16.

ggscatterstats <- function(data,
^

R/ggwithinstats.R:75:1: style: functions should have cyclomatic complexity of less than 15, this has 27.

ggwithinstats <- function(data,
^

tests/testthat/test-ggbetweenstats.R:91:13: style: Commented code should be removed.

#       bold("only significant")
            ^~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-ggwithinstats.R:176:17: style: Commented code should be removed.

#       bold("only significant")
                ^~~~~~~~~~~~~~~~~~~~~~~~

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-raw/Titanic_full.R:16:10: warning: 1:nrow(...) is likely to be wrong in the empty edge case, use seq_len.

df[rep(1:nrow(df), rep), ]
         ^

R/ggbarstats.R:44:1: style: functions should have cyclomatic complexity of less than 15, this has 16.

ggbarstats <- function(data,
^

R/ggbetweenstats.R:165:1: style: functions should have cyclomatic complexity of less than 15, this has 24.

ggbetweenstats <- function(data,
^

R/ggcoefstats.R:133:1: style: functions should have cyclomatic complexity of less than 15, this has 43.

ggcoefstats <- function(x,
^

R/ggcorrmat.R:97:1: style: functions should have cyclomatic complexity of less than 15, this has 18.

ggcorrmat <- function(data,
^

R/ggcorrmat.R:159:3: warning: local variable ‘corr.nature’ assigned but may not be used

corr.nature <- ifelse(isTRUE(partial), "correlation (partial):", "correlation:")
  ^~~~~~~~~~~

R/ggcorrmat.R:191:3: warning: local variable ‘getmode’ assigned but may not be used

getmode <- function(v) {
  ^~~~~~~

R/ggpiestats.R:71:1: style: functions should have cyclomatic complexity of less than 15, this has 29.

ggpiestats <- function(data,
^

R/ggscatterstats.R:96:1: style: functions should have cyclomatic complexity of less than 15, this has 16.

ggscatterstats <- function(data,
^

R/ggwithinstats.R:75:1: style: functions should have cyclomatic complexity of less than 15, this has 27.

ggwithinstats <- function(data,
^

tests/testthat/test-ggbetweenstats.R:91:13: style: Commented code should be removed.

#       bold("only significant")
            ^~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-ggwithinstats.R:176:17: style: Commented code should be removed.

#       bold("only significant")
                ^~~~~~~~~~~~~~~~~~~~~~~~

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-raw/Titanic_full.R:16:10: warning: 1:nrow(...) is likely to be wrong in the empty edge case, use seq_len.

df[rep(1:nrow(df), rep), ]
         ^

R/ggbarstats.R:44:1: style: functions should have cyclomatic complexity of less than 15, this has 16.

ggbarstats <- function(data,
^

R/ggbetweenstats.R:165:1: style: functions should have cyclomatic complexity of less than 15, this has 24.

ggbetweenstats <- function(data,
^

R/ggcoefstats.R:133:1: style: functions should have cyclomatic complexity of less than 15, this has 43.

ggcoefstats <- function(x,
^

R/ggcorrmat.R:97:1: style: functions should have cyclomatic complexity of less than 15, this has 18.

ggcorrmat <- function(data,
^

R/ggpiestats.R:71:1: style: functions should have cyclomatic complexity of less than 15, this has 29.

ggpiestats <- function(data,
^

R/ggscatterstats.R:96:1: style: functions should have cyclomatic complexity of less than 15, this has 16.

ggscatterstats <- function(data,
^

R/ggwithinstats.R:75:1: style: functions should have cyclomatic complexity of less than 15, this has 27.

ggwithinstats <- function(data,
^

tests/testthat/test-ggbetweenstats.R:91:13: style: Commented code should be removed.

#       bold("only significant")
            ^~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-ggwithinstats.R:176:17: style: Commented code should be removed.

#       bold("only significant")
                ^~~~~~~~~~~~~~~~~~~~~~~~

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-raw/Titanic_full.R:16:10: warning: 1:nrow(...) is likely to be wrong in the empty edge case, use seq_len.

df[rep(1:nrow(df), rep), ]
         ^

R/ggbarstats.R:44:1: style: functions should have cyclomatic complexity of less than 15, this has 16.

ggbarstats <- function(data,
^

R/ggbetweenstats.R:165:1: style: functions should have cyclomatic complexity of less than 15, this has 24.

ggbetweenstats <- function(data,
^

R/ggcoefstats.R:133:1: style: functions should have cyclomatic complexity of less than 15, this has 43.

ggcoefstats <- function(x,
^

R/ggcorrmat.R:97:1: style: functions should have cyclomatic complexity of less than 15, this has 18.

ggcorrmat <- function(data,
^

R/ggcorrmat.R:159:3: warning: local variable ‘corr.nature’ assigned but may not be used

corr.nature <- ifelse(isTRUE(partial), "correlation (partial):", "correlation:")
  ^~~~~~~~~~~

R/ggcorrmat.R:191:3: warning: local variable ‘getmode’ assigned but may not be used

getmode <- function(v) {
  ^~~~~~~

R/ggpiestats.R:71:1: style: functions should have cyclomatic complexity of less than 15, this has 29.

ggpiestats <- function(data,
^

R/ggscatterstats.R:96:1: style: functions should have cyclomatic complexity of less than 15, this has 16.

ggscatterstats <- function(data,
^

R/ggwithinstats.R:75:1: style: functions should have cyclomatic complexity of less than 15, this has 27.

ggwithinstats <- function(data,
^

tests/testthat/test-ggbetweenstats.R:91:13: style: Commented code should be removed.

#       bold("only significant")
            ^~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-ggwithinstats.R:176:17: style: Commented code should be removed.

#       bold("only significant")
                ^~~~~~~~~~~~~~~~~~~~~~~~

Please sign in to comment.