Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc cleanup #52

Merged
merged 13 commits into from
Feb 1, 2024
Prev Previous commit
Next Next commit
Add dplyr and tibble :: in vignettes
olivroy committed Jan 31, 2024
commit 782c8f6d4cd107392af9cd6bba5874ef62976273
2 changes: 1 addition & 1 deletion vignettes/debit.Rmd
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ As in `grim()`, the mean needs to be a string. (The same is true for the SD.) Th
If you want to test more than a handful of cases, the recommended way is to enter them into a data frame and to run `debit_map()` on the data frame. Below are the example data from Heathers and Brown's (2019) Table 1. A useful way to enter such data is to copy them from a PDF file and paste them into `tibble::tribble()`, which is available via scrutiny:

```{r}
flying_pigs <- tibble(
flying_pigs <- tibble::tibble(
x = runif(5, 0.2, 1) %>% round(2) %>% restore_zeros(),
sd = runif(5, 0, 0.3) %>% round(2) %>% restore_zeros(),
n = 1000
16 changes: 8 additions & 8 deletions vignettes/grim.Rmd
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ If you want to GRIM-test more than a handful of cases, the recommended way is to
Copy summary data from a PDF file and paste them into `tibble::tribble()`, which is available via scrutiny:

```{r}
flying_pigs1 <- tribble(
flying_pigs1 <- tibble::tribble(
~x,
"8.97",
"2.61",
@@ -69,7 +69,7 @@ flying_pigs1 <- tribble(
"10.46",
"7.39"
) %>%
mutate(n = 28)
dplyr::mutate(n = 28)
```

Use RStudio's multiple cursors to draw quotation marks around all the `x` values, and to set commas at the end. See `vignette("wrangling")`, section *With copy and paste*, if you are not sure how to do that.
@@ -87,7 +87,7 @@ The `x` and `n` columns are the same as in the input. By default, the number of
If a mean is composed of multiple items, set the `items` parameter to that number. Below are hypothetical means of a three-items scale. With the single-item default, half of these are wrongly flagged as inconsistent:

```{r, error=TRUE}
jpap_1 <- tribble(
jpap_1 <- tibble::tribble(
~x,
"5.90",
"5.71",
@@ -96,7 +96,7 @@ jpap_1 <- tribble(
"4.61",
"5.24",
) %>%
mutate(n = 40)
dplyr::mutate(n = 40)

jpap_1 %>%
grim_map() # default is wrong here!
@@ -112,7 +112,7 @@ jpap_1 %>%
It is also possible to include an `items` column in the data frame instead:

```{r, error=TRUE}
jpap_2 <- tribble(
jpap_2 <- tibble::tribble(
~x, ~items,
"6.92", 1,
"3.48", 1,
@@ -134,7 +134,7 @@ An underappreciated strength of GRIM is testing percentages. Since these are act
Both `grim()` and `grim_map()` have a `percent` parameter which, if set to `TRUE`, divides the `x` values by 100 and increases the decimal count by two, so that percentages can be tested just like means:

```{r}
jpap_3 <- tribble(
jpap_3 <- tibble::tribble(
~x, ~n,
"32.5", 438,
"35.6", 455,
@@ -246,7 +246,7 @@ These columns are ---
There is a specialized visualization function for GRIM test results, `grim_plot()`:

```{r, error=TRUE, fig.width=6, fig.height=5.5}
jpap_5 <- tribble(
jpap_5 <- tibble::tribble(
~x, ~n,
"7.19", 28,
"4.56", 34,
@@ -357,7 +357,7 @@ More precisely, they went from a 20/20 group split to a 19/21 split, then to an
Instead of going about this manually, call `grim_map_total_n()`, followed by `audit_total_n()` for summarizing the results. It will find two further plausible scenarios in which both means are consistent; more on that below.

```{r}
df <- tibble(x1 = "4.71", x2 = "5.3", n = 40)
df <- tibble::tibble(x1 = "4.71", x2 = "5.3", n = 40)

# Detailed results:
df_tested <- grim_map_total_n(df)
14 changes: 7 additions & 7 deletions vignettes/grimmer.Rmd
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ If you want to GRIMMER-test more than a handful of cases, the recommended way is
Copy summary data from a PDF file and paste them into `tibble::tribble()`, which is available via scrutiny:

```{r}
flying_pigs1 <- tribble(
flying_pigs1 <- tibble::tribble(
~x, ~sd,
"8.9", "2.81",
"2.6", "2.05",
@@ -69,7 +69,7 @@ flying_pigs1 <- tribble(
"10.4", "2.53",
"7.3", "3.14"
) %>%
mutate(n = 25)
dplyr::mutate(n = 25)
```

Use RStudio's multiple cursors to draw quotation marks around all the `x` and `sd` values, and to set commas at the end. See `vignette("wrangling")`, section *With copy and paste*, if you are not sure how to do that.
@@ -91,7 +91,7 @@ The `reason` column says why a set of values was inconsistent. To be GRIMMER-con
If a mean is composed of multiple items, set the `items` parameter to that number. Below are hypothetical means of a three-items scale. With the single-item default, half of these are wrongly flagged as inconsistent:

```{r, error=TRUE}
jpap_1 <- tribble(
jpap_1 <- tibble::tribble(
~x, ~sd,
"5.90", "2.19",
"5.71", "1.42",
@@ -100,7 +100,7 @@ jpap_1 <- tribble(
"4.61", "1.92",
"5.24", "2.51",
) %>%
mutate(n = 40)
dplyr::mutate(n = 40)

jpap_1 %>%
grimmer_map() # default is wrong here!
@@ -116,7 +116,7 @@ jpap_1 %>%
It is also possible to include an `items` column in the data frame instead:

```{r, error=TRUE}
jpap_2 <- tribble(
jpap_2 <- tibble::tribble(
~x, ~sd, ~items,
"6.92", "2.19", 1,
"3.48", "1.42", 1,
@@ -125,7 +125,7 @@ jpap_2 <- tribble(
"4.04", "1.92", 3,
"4.50", "2.51", 3,
) %>%
mutate(n = 30)
dplyr::mutate(n = 30)

jpap_2 %>%
grimmer_map()
@@ -176,7 +176,7 @@ These columns are ---
GRIMMER does not currently have a dedicated visualization function in scrutiny. However, `grim_plot()` will accept the output of `grimmer_map()` just as well as that from `grim_map()`:

```{r, fig.width=6, fig.height=5.5}
jpap_5 <- tribble(
jpap_5 <- tibble::tribble(
~x, ~sd, ~n,
"7.19", "1.19", 54,
"4.56", "2.56", 66,
8 changes: 4 additions & 4 deletions vignettes/wrangling.Rmd
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ Perhaps not all R users know that RStudio features an option for multiple cursor
You should then get something like this:

```{r}
flights1 <- tribble(
flights1 <- tibble::tribble(
~x,
"8.97",
"2.61",
@@ -70,7 +70,7 @@ All that's missing is the sample size. Add it either via another `tribble()` col

```{r}
flights1 <- flights1 %>%
mutate(n = 28)
dplyr::mutate(n = 28)

flights1
```
@@ -111,7 +111,7 @@ vec %>%
A convenient way to restore trailing zeros in a data frame is `restore_zeros_df()`. By default, it operates on all columns that are coercible to numeric (factors don't count):

```{r}
iris <- as_tibble(iris)
iris <- tibble::as_tibble(iris)
iris %>%
restore_zeros_df(width = 3)
```
@@ -130,7 +130,7 @@ iris %>%
With summary data copied or extracted from PDF (see above), you might encounter values presented like `5.22 (0.73)`. Instead of manually teasing them apart, call `split_by_parens()`:

```{r}
flights2 <- tribble(
flights2 <- tibble::tribble(
~drone, ~selfpilot,
"0.09 (0.21)", "0.19 (0.13)",
"0.19 (0.28)", "0.53 (0.10)",