Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughjonesd/santoku
A versatile cutting tool for R
https://github.com/hughjonesd/santoku
Last synced: 6 days ago
JSON representation
A versatile cutting tool for R
- Host: GitHub
- URL: https://github.com/hughjonesd/santoku
- Owner: hughjonesd
- License: other
- Created: 2019-08-30T15:41:46.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-20T11:11:52.000Z (8 months ago)
- Last Synced: 2025-02-06T07:08:43.884Z (14 days ago)
- Language: JavaScript
- Homepage: https://hughjonesd.github.io/santoku
- Size: 19.2 MB
- Stars: 138
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - hughjonesd/santoku - A versatile cutting tool for R (JavaScript)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)```
# santoku
[](https://CRAN.R-project.org/package=santoku)
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
[](https://CRAN.R-project.org/package=santoku)
[](https://hughjonesd.r-universe.dev/santoku)
[](https://github.com/hughjonesd/santoku/actions)
[](https://app.codecov.io/gh/hughjonesd/santoku?branch=master)santoku is a versatile cutting tool for R. It provides `chop()`, a replacement
for `base::cut()`.## Installation
Install from [r-universe](https://r-universe.dev):
``` r
install.packages("santoku", repos = c("https://hughjonesd.r-universe.dev",
"https://cloud.r-project.org"))
```Or from CRAN:
``` r
install.packages("santoku")
```Or get the development version from github:
``` r
# install.packages("remotes")
remotes::install_github("hughjonesd/santoku")
``````{r, child = 'advantages.Rmd'}
```## Examples
```{r}
library(santoku)
````chop` returns a factor:
```{r}
chop(1:5, c(2, 4))
```Include a number twice to match it exactly:
```{r}
chop(1:5, c(2, 2, 4))
```Use names in breaks for labels:
```{r}
chop(1:5, c(Low = 1, Mid = 2, High = 4))
```Or use `lbl_*` functions:
```{r}
chop(1:5, c(2, 4), labels = lbl_dash())
```Chop into fixed-width intervals:
```{r}
chop_width(runif(10), 0.1)
```Or into fixed-size groups:
```{r}
chop_n(1:10, 5)
```Chop dates by calendar month, then tabulate:
```{r}
library(lubridate)dates <- as.Date("2021-12-31") + 1:90
tab_width(dates, months(1), labels = lbl_discrete(fmt = "%d %b"))
```For more information, see the [vignette](https://hughjonesd.github.io/santoku/articles/santoku.html).