-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Minor clean-up translation vignette setup #531
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ vignette: > | |
%\VignetteEngine{knitr::rmarkdown} | ||
--- | ||
|
||
```{r message=FALSE, warning=FALSE, include=FALSE, eval = TRUE} | ||
```{r setup, message=FALSE, warning=FALSE, include=FALSE, eval = TRUE} | ||
library(knitr) | ||
options(knitr.kable.NA = "") | ||
knitr::opts_chunk$set( | ||
|
@@ -21,25 +21,28 @@ knitr::opts_chunk$set( | |
|
||
pkgs <- c( | ||
"dplyr", | ||
"datawizard", | ||
"tidyr" | ||
) | ||
all_deps_available <- all(vapply(pkgs, requireNamespace, quietly = TRUE, FUN.VALUE = logical(1L))) | ||
|
||
# since we explicitely put eval = TRUE for some chunks, we can't rely on | ||
# knitr::opts_chunk$set(eval = FALSE) at the beginning of the script. So we make | ||
# a logical that is FALSE only if deps are not installed (cf easystats/easystats#317) | ||
evaluate_chunk <- TRUE | ||
|
||
if (!all(vapply(pkgs, requireNamespace, quietly = TRUE, FUN.VALUE = logical(1L))) || getRversion() < "4.1.0") { | ||
evaluate_chunk <- FALSE | ||
if (all_deps_available) { | ||
library(datawizard) | ||
library(dplyr) | ||
library(tidyr) | ||
} | ||
|
||
# Since we explicitly put `eval = TRUE` for some chunks, we can't rely on | ||
# `knitr::opts_chunk$set(eval = FALSE)` at the beginning of the script. | ||
# Therefore, we introduce a logical that is `FALSE` only if all suggested | ||
# dependencies are not installed (cf easystats/easystats#317) | ||
evaluate_chunk <- all_deps_available && getRversion() >= "4.1.0" | ||
``` | ||
|
||
This vignette can be referred to by citing the following: | ||
|
||
Patil et al., (2022). datawizard: An R Package for Easy Data Preparation and Statistical Transformations. *Journal of Open Source Software*, *7*(78), 4684, https://doi.org/10.21105/joss.04684 | ||
|
||
```{css, echo=FALSE, eval = evaluate_chunk} | ||
```{css, echo=FALSE, eval = TRUE} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to eval CSS code conditionally. Doesn't hurt us if it is evaluated. |
||
.datawizard, .datawizard > .sourceCode { | ||
background-color: #e6e6ff; | ||
} | ||
|
@@ -97,20 +100,20 @@ efc <- head(efc) | |
Before we look at their *tidyverse* equivalents, we can first have a look at | ||
`{datawizard}`'s key functions for data wrangling: | ||
|
||
| Function | Operation | | ||
| :---------------- | :------------------------------------------------ | | ||
| `data_filter()` | [to select only certain observations](#filtering) | | ||
| `data_select()` | [to select only a few variables](#selecting) | | ||
| `data_modify()` | [to create variables or modify existing ones](#modifying) | | ||
| `data_arrange()` | [to sort observations](#sorting) | | ||
| `data_extract()` | [to extract a single variable](#extracting) | | ||
| `data_rename()` | [to rename variables](#renaming) | | ||
| `data_relocate()` | [to reorder a data frame](#relocating) | | ||
| `data_to_long()` | [to convert data from wide to long](#reshaping) | | ||
| `data_to_wide()` | [to convert data from long to wide](#reshaping) | | ||
| `data_join()` | [to join two data frames](#joining) | | ||
| `data_unite()` | [to concatenate several columns into a single one](#uniting) | | ||
| `data_separate()` | [to separate a single column into multiple columns](#separating) | | ||
| Function | Operation | | ||
| :---------------- | :--------------------------------------------------------------- | | ||
| `data_filter()` | [to select only certain observations](#filtering) | | ||
| `data_select()` | [to select only a few variables](#selecting) | | ||
| `data_modify()` | [to create variables or modify existing ones](#modifying) | | ||
| `data_arrange()` | [to sort observations](#sorting) | | ||
| `data_extract()` | [to extract a single variable](#extracting) | | ||
| `data_rename()` | [to rename variables](#renaming) | | ||
| `data_relocate()` | [to reorder a data frame](#relocating) | | ||
| `data_to_long()` | [to convert data from wide to long](#reshaping) | | ||
| `data_to_wide()` | [to convert data from long to wide](#reshaping) | | ||
| `data_join()` | [to join two data frames](#joining) | | ||
| `data_unite()` | [to concatenate several columns into a single one](#uniting) | | ||
| `data_separate()` | [to separate a single column into multiple columns](#separating) | | ||
|
||
Note that there are a few functions in `{datawizard}` that have no strict equivalent | ||
in `{dplyr}` or `{tidyr}` (e.g `data_rotate()`), and so we won't discuss them in | ||
|
@@ -124,7 +127,7 @@ Before we look at them individually, let's first have a look at the summary tabl | |
| :---------------- | :------------------------------------------------------------------ | | ||
| `data_filter()` | `dplyr::filter()`, `dplyr::slice()` | | ||
| `data_select()` | `dplyr::select()` | | ||
| `data_modify()` | `dplyr::mutate()` | | ||
| `data_modify()` | `dplyr::mutate()` | | ||
| `data_arrange()` | `dplyr::arrange()` | | ||
| `data_extract()` | `dplyr::pull()` | | ||
| `data_rename()` | `dplyr::rename()` | | ||
|
@@ -134,8 +137,8 @@ Before we look at them individually, let's first have a look at the summary tabl | |
| `data_join()` | `dplyr::inner_join()`, `dplyr::left_join()`, `dplyr::right_join()`, | | ||
| | `dplyr::full_join()`, `dplyr::anti_join()`, `dplyr::semi_join()` | | ||
| `data_peek()` | `dplyr::glimpse()` | | ||
| `data_unite()` | `tidyr::unite()` | | ||
| `data_separate()` | `tidyr::separate()` | | ||
| `data_unite()` | `tidyr::unite()` | | ||
| `data_separate()` | `tidyr::separate()` | | ||
|
||
## Filtering {#filtering} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to check if
{datawizard}
is available.