diff --git a/R/lay.R b/R/lay.R index 54f204a..b183458 100644 --- a/R/lay.R +++ b/R/lay.R @@ -7,7 +7,7 @@ #' frame (`.data`) as the vector input of some function(s) `.fn`. #' #' This makes the creation of new columns based on a rowwise operation both simple (see -#' **Examples**; below) and efficient (see the vignette [**benchmarks**](../doc/benchmark.html)). +#' **Examples**; below) and efficient (see the Article [**benchmarks**](https://courtiol.github.io/lay/articles/benchmarks.html)). #' #' The function should be fully compatible with `{dplyr}`-based workflows and follows a syntax close #' to [dplyr::across()]. @@ -49,7 +49,7 @@ #' - "tidy", internally uses [purrr::pmap()] and is stricter with respect to class coercion #' across columns. #' -#' The default has been chosen based on these [**benchmarks**](../doc/benchmark.html). +#' The default has been chosen based on these [**benchmarks**](https://courtiol.github.io/lay/articles/benchmarks.html). #' #' @importFrom vctrs vec_c #' @importFrom rlang list2 exec as_function diff --git a/man/lay.Rd b/man/lay.Rd index 4356c58..d8ca7ae 100644 --- a/man/lay.Rd +++ b/man/lay.Rd @@ -31,7 +31,7 @@ is used to apply the rowwise job: across columns. } -The default has been chosen based on these \href{../doc/benchmark.html}{\strong{benchmarks}}.} +The default has been chosen based on these \href{https://courtiol.github.io/lay/articles/benchmarks.html}{\strong{benchmarks}}.} } \description{ Create efficiently new column(s) in data frame (including tibble) by applying a function one row @@ -42,7 +42,7 @@ at a time. frame (\code{.data}) as the vector input of some function(s) \code{.fn}. This makes the creation of new columns based on a rowwise operation both simple (see -\strong{Examples}; below) and efficient (see the vignette \href{../doc/benchmark.html}{\strong{benchmarks}}). +\strong{Examples}; below) and efficient (see the Article \href{https://courtiol.github.io/lay/articles/benchmarks.html}{\strong{benchmarks}}). The function should be fully compatible with \code{{dplyr}}-based workflows and follows a syntax close to \code{\link[dplyr:across]{dplyr::across()}}. diff --git a/vignettes/articles/alternatives.Rmd b/vignettes/articles/alternatives.Rmd index 2ee089f..be90d77 100644 --- a/vignettes/articles/alternatives.Rmd +++ b/vignettes/articles/alternatives.Rmd @@ -1,5 +1,5 @@ --- -title: "Alternatives to `lay()`" +title: "Alternatives for rowwise jobs" --- ```{r, include = FALSE} @@ -12,13 +12,13 @@ knitr::opts_chunk$set( ## Article overview There are many alternatives to perform rowwise jobs in R. -In this article, we consider, in turns, these alternatives. +In this Article, we consider, in turns, these alternatives. We will stick to our example about drugs usage shown in [introduction](https://courtiol.github.io/lay/). The idea is to compare alternative ways to create a new variable named `everused` which indicates if each respondent has used any of the considered pain relievers for non medical purpose or not. ## Loading packages -This article requires you to load the following packages: +This Article requires you to load the following packages: ```{r load_pkg, message=FALSE} library(lay) ## for lay() and the data @@ -150,6 +150,6 @@ There are probably other ways. If you think of a nice one, please leave an issue ## Efficiency -The results of a benchmark comparing alternative implementations for our simple rowwise job are shown in another article (see [benchmark](https://courtiol.github.io/lay/articles/benchmark.html)). +The results of benchmarks comparing alternative implementations for our simple rowwise job are shown in another Article (see [benchmarks](https://courtiol.github.io/lay/articles/benchmarks.html)). As you will see, `lay()` is not just simple and powerful, it is also quite efficient! diff --git a/vignettes/articles/benchmark.Rmd b/vignettes/articles/benchmarks.Rmd similarity index 92% rename from vignettes/articles/benchmark.Rmd rename to vignettes/articles/benchmarks.Rmd index af00aa3..8c9d48c 100644 --- a/vignettes/articles/benchmark.Rmd +++ b/vignettes/articles/benchmarks.Rmd @@ -1,5 +1,5 @@ --- -title: "Benchmarking alternative implementations for rowwise jobs" +title: "Benchmarks" --- ```{r, include = FALSE} @@ -11,7 +11,7 @@ knitr::opts_chunk$set( ## Article overview -The goal of this article is to compare the performances of `lay()` to alternatives described [here](https://courtiol.github.io/lay/articles/alternatives.html). +The goal of this Article is to compare the performances of `lay()` to alternatives described [here](https://courtiol.github.io/lay/articles/alternatives.html). As you will see, the code using `lay()` is quite efficient. The only alternative that is clearly more efficient is the one labeled below "*vectorized*". Unfortunately, such a vectorized approach imply to refer explicitly to all column names which data are used. @@ -21,7 +21,7 @@ and arithmetic operators and does allow the use of other types of functions. ## Loading packages -This article requires you to load the following packages: +This Article requires you to load the following packages: ```{r load_pkg, message=FALSE} library(lay) ## for lay() and the data @@ -30,8 +30,8 @@ library(tidyr) ## for pivot_longer() and pivot_wider() library(purrr) ## for pmap_lgl() library(slider) ## for slide() library(data.table) ## for an alternative to base and dplyr -library(bench) ## for running the benchmark -library(forcats) ## for sorting levels in benchmark plot with fct_reorder() +library(bench) ## for running the benchmarks +library(forcats) ## for sorting levels in plot with fct_reorder() ``` Please install them if they are not present on your system. @@ -55,9 +55,9 @@ drugs_full |> pivot_wider(names_from = used, values_from = n) ``` -In this article, we compare the efficiency of alternative ways to create a new variable named `everused` which indicates if each respondent has used any of the considered pain relievers for non medical purpose or not. +In this Article, we compare the efficiency of alternative ways to create a new variable named `everused` which indicates if each respondent has used any of the considered pain relievers for non medical purpose or not. -## Benchmark +## Benchmarks Let's compare the running time of different methods to do this job: @@ -189,7 +189,7 @@ benchmark2 |> Note again that the x-axis of the plot is on a logarithmic scale. -## Benchmark environment +## Benchmarks' environment ```{r session} sessionInfo()