knitr::opts_chunk$set( collapse = TRUE, comment = "#>", out.width = "100%" )
Development version can be installed from GitHub with:
# install.packages("devtools") devtools::install_github("Ilia-Kosenkov/primitiveR")
library(purrr) library(vctrs) library(primitiveR)
primitiveR
allows for type-preserving and structure-preserving mappings (at least while purrr
does not fully support it).
mtcars[1:5,1:3] %>% map(~.x) mtcars[1:5,1:3] %>% vmap(~.x)
The *map_pt
version has an optional .ptype
argument that can be used to select the output type. By default, it will result into the following:
mtcars[1:3,1:3] %>% vmap(~.x) -> x x x %>% vmap_pt(~.x)
1:10 %>% vmap_if(~.x > 5, ~1L, .else = ~0L) %>% as_vec
primitiveR
provides floating-point equality extension using %==%
and %!=%
, which operate as normal ==
and !=
for vector types.
0.1 + 0.2 == 0.3 (0.1 + 0.2) %==% 0.3
%===%
and %!==%
are particular useful in conditions, because these operators apply all
/any
to the output of %==%
or %!=%
.
(1:5) %!=% 1 (1:5) %!==% 1 (1:5) %==% (1:5) (1:5) %===% (1:5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.